Cancel Row selection after handling HyperlinkOpening

2 posts, 0 answers
  1. Keith
    Keith avatar
    1 posts
    Member since:
    Feb 2016

    Posted 06 May Link to this post

    Hello Support,

      I have two Gridviews, when an item on the top grid is selected, the bottom grid populates with content related to the selection that is displayed by handling the SelectionChanged() event.  I grid also includes GridViewHyperlinkColumn()s which show a popup window by handling the HyperlinkOpening() event.

    Currently, when I click on a hyperlink on a row that is not selected, my dialog opens up.  When I close the dialog the row is selected is the bottom content opens up.

    The behavior I would like is that when I click a hyperlink, the row is not selected.  Or, when clicking the hyperlink, the row is selected, then the hyperlinkOpening() is handled.

    What is the recommended way to accomplish this?


  2. Hristo Merdjanov
    Hristo Merdjanov avatar
    674 posts

    Posted 09 May Link to this post

    Hi Keith,

    Thank you for writing.

    RadGridView exposes several data validation events and the RowValidating event is suitable to be handled in your type of scenario: Data Validation.

    In order to achieve your task, you would need to cancel the RowValidating every time you open your dialog int the HyperlinkOpening event you are already handling. Please check my code snippet below: 
    public partial class Form1 : Form
        public Form1()
            GridViewDecimalColumn decColumn = new GridViewDecimalColumn("Row");
            GridViewHyperlinkColumn column = new GridViewHyperlinkColumn("Hyperlink column");
            column.HyperlinkOpenArea = HyperlinkOpenArea.Cell;
            this.radGridView1.Rows.Add(1, "Show Popup");
            this.radGridView1.Rows.Add(2, "Show Popup");
            this.radGridView1.Rows.Add(3, "Show Popup");
            this.radGridView1.Rows.Add(4, "Show Popup");
            this.radGridView1.Rows.Add(5, "Show Popup");
            this.radGridView1.Rows.Add(6, "Show Popup");
            this.radGridView1.Rows.Add(7, "Show Popup");
            this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
            this.radGridView1.RowValidating += radGridView1_RowValidating;
            this.radGridView1.HyperlinkOpening += radGridView1_HyperlinkOpening;
        private void radGridView1_RowValidating(object sender, RowValidatingEventArgs e)
            if (cancelRowSelection)
                e.Cancel = true;
            cancelRowSelection = false;
        bool cancelRowSelection = false;
        private void radGridView1_HyperlinkOpening(object sender, HyperlinkOpeningEventArgs e)
            Form dialog = new Form() { Text = "Dialog" };
            cancelRowSelection = true;

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Hristo Merdjanov
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft banner
Back to Top