Odd error in RadGridView

1 Answer 43 Views
GridView
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Carl asked on 05 Jun 2024, 06:23 PM

I'm experiencing weird behavior when trying to remove a row using v2023.3.1114. I created a test form in my main app and launch it like this:

Form1 form = new();

form.ShowDialog();

The form populates a grid  by setting the DataSource to a collection of POCOs.

The grid has a a hyperlink column. When the user clicks the column, the goal is to have the clicked row disappear. I'm implementing it like this:

private void gvTaskNotifyType_HyperlinkOpening(object sender, HyperlinkOpeningEventArgs e)

{
    try
    {
        int rowIndex = e.Row.Index;

        gvTaskNotifyType.Rows.RemoveAt(rowIndex);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }

}

 

Problem is when the RemoveAt() method is called it throws a Object reference not set to an instance of an object . It may happen the first time or more often the 3rd. It also happens if I use Remove() and pass in a reference to the row object and also if I try to set the IsVisible property to false. The really strange part is that the error doesn't enter the catch handler. Rather, its stops on the form.ShowDialog(); line and breaks there.

Any ideas?

Carl

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 10 Jun 2024, 10:15 AM

Hello, Carl,

GridViewHyperlinkColumn offers two events HyperlinkOpening/HyperlinkOpened. HyperlinkOpening event triggers too early, before the hyperlink is opened. Is it possible to use the HyperlinkOpened instead? It triggers after the hyperlink gets opened. 

I created an example project. Can you please refer to it and let me know how this works for you?

I hope this helps. If you have any further questions, please let me know.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Carl
Top achievements
Rank 1
Iron
Iron
Iron
commented on 10 Jun 2024, 01:59 PM

Thanks, Nadya.

HyperlinkOpened did the trick.

Carl

Tags
GridView
Asked by
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or