CurrentRow

4 posts, 0 answers
  1. Kuba
    Kuba avatar
    13 posts
    Member since:
    Aug 2013

    Posted 10 Sep 2013 Link to this post

    I have a problem with getting CurrentRow Index.

    private void myRadGridView_DefaultValuesNeeded(object sender, Telerik.WinControls.UI.GridViewRowEventArgs e)
    {
          int index = e.Row.Index;
          int index2 = this.myRadGridView.CurrentRow.Index;
    }

    Both ways give me one result: -1
    My GridView is bound with dataSet.
    How can I get CurrentRow Index in DefalutValuesNeeded event?

    Help for thanks.

    Kuba
  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3948 posts

    Posted 13 Sep 2013 Link to this post

    Hello Kuba,

    Thank you for contacting Telerik Support.

    You can initialize the new row in RadGridView by handling the DefaultValuesNeeded event. This event fires after clicking the "add new row" link and before entering edit mode. It is normal to obtain index of the current row -1, because this new row is still not a part of the grid data because, you have not committed the new row yet. If you need to know on which index the new row will be probably inserted after pressing enter key, you may use:
    private void radGridView1_DefaultValuesNeeded(object sender, GridViewRowEventArgs e)
    {
        int index = e.Row.Index;
        int index2 = this.radGridView1.CurrentRow.Index;
     
        int futureNewRowIndex = this.radGridView1.Rows.Count;
    }

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Szymon
    Szymon avatar
    6 posts
    Member since:
    Sep 2013

    Posted 27 Sep 2013 Link to this post

    Hi!
    I have similar problem to Kuba, but my job is to read from new row not yet inserted to DataGrid. I need to open a new window, which depend on option which is chosen by user in GridView ComboBox, but I can't reach this chosen value. How can I obtain data from new row, while it's not yet part of the grid? 

    Regards,
    Szymon.
  4. Szymon
    Szymon avatar
    6 posts
    Member since:
    Sep 2013

    Posted 01 Oct 2013 Link to this post

    Problem solved. ;)
Back to Top