Home Forums WinForms controls Xceed Grid for WinForms How to determine the Index of the Row at which the cursor is located on Xceed grid for .Net

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16986 |

    Hi,

    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

    Regards,

    Lalit 

     

    Imported from legacy forums. Posted by Lalit (had 4686 views)

    User (Old forums)
    Member
    Post count: 23064

    You can use the CurrentRowChanged event, and find the index in the event handle.

    e.g.:

        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)
    Member
    Post count: 23064

    Hi Andre,

    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,

    Lalit 

     

    Imported from legacy forums. Posted by Lalit (had 3847 views)

    User (Old forums)
    Member
    Post 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)
    Member
    Post count: 23064

    Andre,

    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.

    Andrei

    Imported from legacy forums. Posted by Baducu (had 436 views)

    User (Old forums)
    Member
    Post count: 23064

    This is a post on our.NET Grid, not our WPF grid.

    Please post your questions in our WPF forums : http://xceed.com/CS/forums/35/ShowForum.aspx

    Imported from legacy forums. Posted by André (had 1762 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.