Get current row index at CellEditEnded

1 Answer 54 Views
GridView
Peter
Top achievements
Rank 1
Iron
Iron
Peter asked on 22 Dec 2021, 06:49 AM

Dear Support

I use radgridview in WPF (vb.net), and i spent deays already to figure out how to get the index of the current row.

If the SelectionUnit = Fullrow then its easy, because:

     Dim CurrentRow As Integer = rgv_STATIONS.Items.IndexOf(rgv_STATIONS.SelectedItem)

will give it back . But unfortunately i have to use SelectionUnit = Cell. With this setting the above CurrentRow variable always gets -1.

I need to know it in case of CellEditEnded and at SelectedCellsChanged events. Getting the column index in the same places is easy, but please help me to find the rowindex as well, i lost half of my hair already due to this :)

 

Thank you

Peter

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 24 Dec 2021, 10:10 AM

Hi Peter,

Below are code snippets for accessing the current item via the GridViewSelectedCellsChangedEventArgs and via the GridViewCellEditEndedEventArgs int heir corresponding events:

        private void clubsGrid_SelectedCellsChanged(object sender, Telerik.Windows.Controls.GridView.GridViewSelectedCellsChangedEventArgs e)
        {
            if (e.AddedCells.Count > 0)
            {
                var cellInfo = e.AddedCells[0];
                var selectedItem = cellInfo.Item;
                int index = this.clubsGrid.Items.IndexOf(selectedItem);
            }
        }

        private void clubsGrid_CellEditEnded(object sender, Telerik.Windows.Controls.GridViewCellEditEndedEventArgs e)
        {
            var item = e.Cell.DataContext;
            var index = this.clubsGrid.Items.IndexOf(item);
        }

I hope C# is not a problem, I guess the approach is clear. However, let me know if you have any further questions.

Regards,
Petar Mladenov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Peter
Top achievements
Rank 1
Iron
Iron
commented on 25 Dec 2021, 06:31 AM

Dear Petar,

This is exactly what i was looking for! Wroks perfectly!

Many many thanks!!!!

Marry christmas  and happy new year!

Peter

 

Tags
GridView
Asked by
Peter
Top achievements
Rank 1
Iron
Iron
Answers by
Petar Mladenov
Telerik team
Share this question
or