I have a grid with cells that can be selected or edited, so when you click on a cell it doesn't go into edit mode. I want to be able to type directly into the cell even though it isn't in edit mode.
The way I usually do this is to trap the key press, go in edit mode, set the editor text to the key that has just been pressed, and finally set the selection position to after the character that has just been entered. This method works fine for simple text editors where the data source is a string.
I'm trying to get it to work with a grid that is bound to business objects and uses a data filter to do the conversion. The problem is that when you set the ActiveCell Value programatically then it doesn't go through the filter so you get a type conversion error.
I could call the Convert method myself (checking that EditorResolved.DataFilter is present) but you have to pass in a EditorDataFilterConvertArgs object and there's no public constructor.
Any ideas on how to get the value to convert (another way of setting the value that does the conversion, maybe) or another way of achieving the same effect?
Thanks,
John.
Hi John,
I don't think you really want to set the Value of the cell in this case, you just want to set the Text. You can't set the Text property of a cell, but in this case, the cell is in edit mode, so you can set the Text property on the EditorResolved of the cell.
I think that will work, but if it does not, then you can try setting the text on the TextBox control that is placed over the cell when it is in edit mode. You can get this control via grid.Controls[0] and cast it to a TextBox, assuming it's not null.
Hi,
I couldn't find a Text property on the EditorResolved of the cell. There's a Value property and a CurrentEditText property that's read-only (foiled again).
I had better luck with grid.Controls(0).Text, which works fine (didn't even have to cast it).