User (Old forums)MemberApril 9, 2009 at 12:22 pmPost count: 23064
I am using xceed grid for .NET. I am moving accross the grid using the Up & Down arrow keys. How do I determine the Index of the current row on which the cursor is located.
Doesnt the current row value change when we mpve across the grid using keyboard.
Can any please help on this.
Thanks in advance
Imported from legacy forums. Posted by Lalit (had 4686 views)User (Old forums)MemberApril 9, 2009 at 2:16 pmPost count: 23064
You can use the CurrentRowChanged event, and find the index in the event handle.
private void Form1_Load( object sender, EventArgs e )
gridControl1.CurrentRowChanged += new EventHandler( gridControl1_CurrentRowChanged );
void gridControl1_CurrentRowChanged( object sender, EventArgs e )
Xceed.Grid.DataRow row = gridControl1.CurrentRow as Xceed.Grid.DataRow;
//If the row is null, it means the current row is not a data row, but another row like a group header row.
if( row != null )
//This will give the index of the row in the GridControl.DataRows collection.
Debug.WriteLine( row.Index.ToString() );
//Or this will give the index of the row in the sorted rows collection (if the grid is sorted or grouped).
Debug.WriteLine( gridControl1.GetSortedDataRows( true ).IndexOf( row ).ToString() );
Imported from legacy forums. Posted by André (had 2247 views)User (Old forums)MemberApril 10, 2009 at 1:23 amPost count: 23064
Thanks for your reply, but the solution doesnt work. The problem is suppose that the focus is on a particular cell & if I press the down / up arrow key the CurrentRowCahnged event doesnt get fired. I guess the CurrentRowChanged event gets fired when my entire previous row is selected & I press an up or down key. In my case neither the row nor the cell are selected. ITs just the focus is on a cell & when I move the up & down arrow the event doesnt get fired. Any way to get the index of the row on which the focus is currently. I hope I could explain the problem correctly. Looking forward for your help.
Thanks & Regards,
Imported from legacy forums. Posted by Lalit (had 3847 views)User (Old forums)MemberApril 14, 2009 at 4:39 pmPost count: 23064
I cannot reproduce your issue here, the CurrentRowChanged gets fired all the time. I don’t understand what you by “In my case neither the row nor the cell are selected”. For Up/Down arrows to work, the grid must have the focus, thus a row or cell must be selected. How is your grid set up?
It is possible there is an exception which is swallowed by the grid or the .NET framework, which may explain the issue you are having.
For trapping exceptions, you need to set the debugger to break on all exceptions. Go to Debug Menu -> Exceptions -> Common Language Runtime Exceptions, and select “Thrown” CheckBox.
Also make sure the “Enable Just My Code” CheckBox is unselected (Tools Menu -> Options -> Debugging -> General) if you’re using VS 2005 or up.
This will make sure that no exceptions are swallowed by the grid or the framework, and that the debugger will break in any part of the code, not just yours. It should give you the necessary information to make your code work.
Imported from legacy forums. Posted by André (had 2262 views)User (Old forums)MemberAugust 19, 2009 at 3:31 amPost count: 23064
I have a Xceed.Wpf.DataGrid.DataCell and I use
DataRow crrRow = crrCell.ParentRow as Xceed.Wpf.DataGrid.DataRow;
I can’t seem to find the Index property on crrRow.
Thanks for your help in advance.
Imported from legacy forums. Posted by Baducu (had 436 views)
- You must be logged in to reply to this topic.