Isreadonly column?

Mar 31, 2009 at 9:36 AM
Edited Mar 31, 2009 at 9:36 AM
I have a datagrid , it has two columns  A , B
I have set CanUserAddRows=false, when the button "Add"  in the bottom of the page  be cliked
a new row was inserted.

My problem is ,I want column B to be readonly so that users can not change the values of  the column,
but when the add button clicked, the Cell in column B and new Row is Readonly too---So that i can't
fill in values in it.

How can i make the cell can be written temporarily so that i can fill in it?
Any help would be appreciated , thx
Coordinator
Mar 31, 2009 at 12:21 PM
You could temporarily make it read/write when the user presses the "Add" button.  As soon as the edits to the new row are committed, change it back to read only.
Mar 31, 2009 at 2:54 PM
Thanks for your reply,vinsibal.
First:  I wonder if i can just make the new added cell writable with the others in the same column remaining readonly. 
like  GetCell(datagrid,datagrid.Items.count-1,1).IsReadOnly = true?

Second:  The only solution is  to temporarily make the column B.isreadonly = false.Here I must  keep the focus on the new added row
so that people would not leave here to change the values in the other rows ,and even worse, to move the focus out of this datagrid .  
I  tried to listen  lostfocus and lostkeyboardfocus event ,but it doen't work well.
 How can i make sure of  the added row being locked when edited?
I have read you post about  Locking rows in Datagrid , but i found it really did't help me because there is no "add" in your example.
Thanks for you help.
Coordinator
Mar 31, 2009 at 4:37 PM
Instead of listening to focus changes, why not listen for a RowEditEnding event (which will handle all the focus commiting scenarios).  In that event you can set that particular column back to IsReadOnly. 
Apr 1, 2009 at 1:12 AM
Thanks, i'll try now