This project is read-only.

DataGrid ReadOnly

Nov 2, 2009 at 7:41 AM

How can i set ReadOnly for a SourceGrid.DataGrid?

Nov 3, 2009 at 12:29 PM

Readonly for what? For row, column, cell, whole grid?

Nov 3, 2009 at 1:17 PM

whole grid......all cells

Nov 4, 2009 at 10:20 AM
Edited Nov 4, 2009 at 10:21 AM

You can define this behaviour with the Cell Editors:

SourceGrid.Cells.Editors.EditorBase cEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
cEditor.EnableEdit = false;

I don't think that there is a global property for the whole grid (?)

Nov 4, 2009 at 11:06 AM

Yes, that's the best solutions. There's not need to have property for whole grid

Jul 5, 2010 at 2:51 PM

A Readonly property for the whole grid could be useful for several reasons. The easiest is for a file editor, when you open a file as ready-only. You don't want to disable the whole grid navigation (arrows, mouse, selection eg for copy to clipboard), but you want to disable the edit functions. A global property would avoid to change all the cell editors when you change the file state (disable read-only).

Jul 11, 2010 at 8:31 AM

Jray, you are right, imho. Sometimes global readonly property would make sense

Jul 12, 2010 at 6:21 AM

Isn't the DataSource of your DataGrid set to a BoundList? BoundList has a property called AllowEdit, all you need to do is set it to false. Other useful properties include AllowSort (list will not be sorted when the user clicks on a header), AllowNew (gets rid of the blank row at the end of your grid), AllowDelete (prevents the user from deleting items from the grid).

Jul 12, 2010 at 8:55 AM

Ha ha, cerilia beat us all :)

Jul 12, 2010 at 6:56 PM

Actually, I only know this thanks to Lafrinks. He introduced us both to AllowNew about a year ago. :)

Jul 14, 2010 at 4:38 PM

I don't have a BoundList (managing the sources myself with several file parsers), but thanks for the advice.

I've added a SetReadOnly method for my use, not complicated. Problem is only when a SourceGird update is published, but I've already had to make corrections/extensions for my use...


Aug 26, 2010 at 3:50 PM

Glad I'm still remembered here :) That's remind me that I have patches to submit :)

Anyway the best option in my opinion would be to just extend either BoundListBase or BoundList classes to add custom sources for DataGrid