I’m about to pull my hair out for something that is probably very simple.
This is using the XtraGrid.
Let’s assume I have two columns and x number of rows, contained in one column is just a checkbox that I set with the columnedit property and the other is a value. I have a text box set to be the editor of this second value.
How can I set this up so that if I check the checkbox for that row, it will allow editing to the number in the value field next to it? I have the allowedit set to true for the checkbox column, but if I set the allowedit to true for the 2nd column in say the checkbox checkedchanged event handler, it will allow all of the cells in that column to be edited. I have no other properties like readonly set or anything like that.
How can I distinguish between a single cell in that column and activate the editor while leaving the others readonly based on that checkbox in the same row? I have a feeling it involves using ShowingEditor and CustomRowCellEdit, but I’m not sure how to set that up.
Could someone take me through what I would need to do in order to accomplish this? What settings do I need to put for the readonly/allowedit properties for this column and what would I need to put in those ShowingEditor/CustomRowCellEdit methods to do this? I’m really new at this so it is probably a really basic question, but I need some help! Some code examples for C# to determine which cell is selected would help me, but I just need to figure this out. Thanks!!!
Yes your are right, you have to manage this by implementing the
ShowingEditorEventThis code for demonstration porpuses:
First I bond the
gridview1to aRandomClassthen implement the
ShowingEditorEvent, Every time thegridview1tries to open the editor for thesecond columnit checks whetherAllowEditcolumn checked or not and take action according to it