We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ReadOnly Problem

I have a grid that enables ReadOnly on a per cell basis for the whole grid. Based on user input I disable the ReadOnly property for certain cells, but they will not change to ReadOnly = false now. This process used to work in the 1.6.xx.xx version and we just noticed it does not work with the 2.x update. I''ve written a small test program that demonstrates the problem. If you press one button it sets ReadOnly= True for all cells of the grid. Then when you press the other to set ReadOnly = False the control ignores the assignment and the cells stay readOnly. TIA Patrick WindowsApplication7_2636.zip

8 Replies

AD Administrator Syncfusion Team October 18, 2004 07:22 PM UTC

Setting a cell ReadOnly also makes it ReadOnly for programatic changes too. To change a ReadOnly cell, you first need to set grid.IgnoreReadOnly = true, then make the change, then reset the IgnoreReadOnly property.
GridControl1.IgnoreReadOnly = True
For i = 1 To 10
     For j = 1 To 10
           GridControl1(i, j).ReadOnly = False
     Next
Next
GridControl1.IgnoreReadOnly = False


PA Patrick October 19, 2004 01:32 PM UTC

You missed what I was trying to do. I look all cells on a row until the user selects a value from a dropdown combo. Then I unlock a row for the user to enter data. I''m not trying to programatically input data. If you ran the test program you would see that then it starts you can input data manually. Press the readonly-on button and your locked out. Press the readonly-off button and you still can''t type in data. If you step through with a debugger when you step throught the line in button2_click that sets the readonly property to false it will not change. It stays True if you watch it in the watch window. Like I said this was not a problem in the 1.6.x version of your grid product. Patrick


AD Administrator Syncfusion Team October 19, 2004 03:24 PM UTC

>>Then I unlock a row for the user to enter data How do you unlock the row? From your code, it looks like you are looping through the cells and trying to change the ReadOnly property (programatically). Is this what you want to do? Loop through the cells and turn a ReadOnly cell into a non-readonly cell? If so, then you will have to set grid.IgnoreReadOnly = true in order to do this. A cell set to ReadOnly can not have any property changed (Text, BackColor, Font,... ReadOnly) unless you tell the grid to ignore the readonly flag. If I have misunderstood what you what you want, please tell me what you are doing differently than looping through readonly cells, trying to make them not readonly.


PA Patrick October 19, 2004 04:52 PM UTC

Ok, then you guys broke your control from the way it used to work. This worked fine in the 1.6.xx version. The IgnoreReadOnly doesn''t make sense becase it works on the whole grid not a cell. Also when I lock all the cells and then turn on the IgnoreReadOnly property it allows the user to type into all the cells. As I understand it the IgnoreReadOnly is supposed to allow you to lock a cell from user input but allow the program to modify the contnents. And speaking of that it doesn''t make any sense to allow the program to set the readonly property but then not be able to turn it off unless you go set another property some where else. I''ve never liked the idea that you would lock cells from the program, it''s not need. All I need is to be able to lock/unlock cells individually form the program side. Like I said it used to work fine but for some reason the functionality in your control changed. Patrick


PA Patrick October 19, 2004 05:08 PM UTC

Let me clarify futher, I want to be able to lock cells, from user input. I don''t care about locking the grid from programatic changes, I can control that. Depending on the user selection in a combo box I''m going to unlock rows from the top down for the user to input data. I do this on a row by row basis. I can''t have the user accidently entering data in lower rows so I lock them. I want the ReadOnly property to stop user input only, not programitic input. Hope that helps explain things. Patrick


AD Administrator Syncfusion Team October 19, 2004 05:49 PM UTC

To do what you want to do, you must use IgnoreReadOnly to flip the readonly setting. Here is your sample back with both buttons working to flip the readonly propety of the grid cells. I just added the 2 IgnoreReadOnly lines that allow the buttons to change the ReadOnly property. WindowsApplication7_7830.zip


AD Administrator Syncfusion Team October 19, 2004 06:16 PM UTC

I would like to as one question, why did you prgoram the readonly functionality the way you did? Why have it block programatic changes? It doesn''t work like the standard Winform controls. Thanks Patrick


AD Administrator Syncfusion Team October 19, 2004 06:59 PM UTC

The reason is that you programatically changing a cell value triggers the same change events that are triggerred when the user changes something. This means that one event can handle saving all changes. This event does not know what triggerred the change. If the style is ReadOnly and IgnoreReadOnly is false, it will not save the change.

Loader.
Up arrow icon