Hi,
I need to enable some cells of Grid for editing and the remaining cells will be readonly. Kindly note that I neither need complete column editable nor complete row, just few cells in some columns.
I need all the blue shaded column should be editable (like displayed in TextBox) and remaining column readonly (like displayed in TextBlock).
Also note that All my columns will be creating dynamically based on my Datasource. However Number of rows are fixed in my Grid. I tried to create a TemplateColumn for only those column in which I need TextBox but then TextBox is coming in complete Column cells. I am not able to set ReadOnly (Non-Editable) TextBox for other cells in the column.
I am using Infragistic 2010.3. Any help please?
You would probably want to use the CellEnteringEditMode event and set the e.Cancel flag to true for cells that you do not want to enter edit mode.
Thank you for the quick response Darrell. Kindly note that there is no "e.Cancel" flag in "CellEnteringEditMode" event handler. Although I found one property in this handler
e.Editor.Visibility = System.Windows.Visibility.Collapsed
But when user double click on such cell (which will not go to edit mode) then its (display) text will also Hide. Although this cell text come back when you click on other cell but it looks weird.
Secondly I can get Row index using e.Cell.Row.Index but how can identify column index in this event handler so that I can exactly know which cell is this?
Thanks
There is definitely a Cancel property on the Entering event args. There are two properties presented, the Cancel, and the Cell that is going into edit mode.
From the event arg you presented you are in the Entered event (the post event). Here the two properties are the .Cell and the ,Editor.
To find the column that a cell belongs to use the cells .Column property.
Yes you are right. My mistake.
However in our solution, user need to double click on cell to enter in Edit mode. Is there any way to display TextBox by default for these cells so that double click will not be needed?
If you want to show every cell that can be edited in edit mode at all time, you would probably be best off creating a custom column
https://es.infragistics.com/community/blogs/b/devin_rader/posts/creating-custom-columns-for-xamgrid
Normally the grid only supports a single cell going into edit mode (or single row ) so you would need to adjust your display element to be an editor control.
You would also lose the editing events, since you would always be in edit mode.
You might want to look at changing the grid.EditingSettings.IsOnCellActiveEditingEnabled to true. This would put the cell into edit mode whenever it became the active cell, so only a single cell woudl be editable, but you would get the eventing support, and you wouldn't have to write custom column.
Hello Darrell,
I don't know I have to generate a new question now or its OK to put it here.
I have tried to change the background color of few cells which are editable (like shown in above image) but failed. I will appreciate if you point-out any starting point that how can I chagne the background color (to blue) of few cells.
M. Irfan