User (Old forums)MemberMarch 14, 2007 at 9:38 amPost count: 23064
I am attempting to set the active row and cell in code and then put the grid into EditMode.
However if I set the SelectedIndex on the grid, the CurrentItem is null, even although the SelectedItem returns the System.Data.DataRowView and the row on grid is visibly selected.
If I cannot get the DataRow that is currently active, I cannot put it in edit mode.
So the question is, how to I set the active row and cell and then cause the grid to go into edit mode from code?
Imported from legacy forums. Posted by Kendrew (had 3036 views)Xceed SupportMemberMarch 14, 2007 at 1:30 pmPost count: 5658
The SelectedItem/SelectedItems/SelectedIndex properties really represents the user selection…
To determine/set what item is current “active”, you need to use the CurrentItem/CurrentColumn property.
myGridControl.CurrentItem = myGridControl.Items;
myGridControl.CurrentColumn = myGridControl.Columns;
DataRow row = myGridControl.ItemContainerGenerator.ContainerFromItem(myGridControl.CurrentItem) as DataRow;
Note: Because of UI virtualization, it is possible that the container returned by the ContainerFromItem() function is null, you would need to exectute a BringIntoView() to compensate this situation.
Imported from legacy forums. Posted by Marcus [Xceed] (had 469 views)User (Old forums)MemberMarch 14, 2007 at 4:53 pmPost count: 23064
Thanks Marc, this works.
As an aside, why does
not work as opposed to row.BeginEdit()?
and further to this, when would you expect us to use the commands versus explicit method calls?
Imported from legacy forums. Posted by Kendrew (had 319 views)Xceed SupportMemberMarch 15, 2007 at 8:28 amPost count: 5658
When we created the BeginEdit, EndEdit and CancelEdit commands, we designed it in such a way that they could be raised on any element “inside” the scope of the DataRow (since edition is tightly linked with the concept of Rows)…
Calling the BeginEdit command on that DataGridControl did not make sense at the time, since the DataGridControl itself was non-editable (i.e Its row were), but at the light of previous comments on the same matter, we are currently considering making it possible to call BeginEdit, EndEdit, CancelEdit directly on the DataGridControl (which would include support for the commands).
Imported from legacy forums. Posted by Marcus [Xceed] (had 4127 views)
- You must be logged in to reply to this topic.