Link Button Type Column in Grid View

4 posts, 0 answers
  1. Santhosh Kumar
    Santhosh Kumar avatar
    3 posts
    Member since:
    Nov 2005

    Posted 11 Aug 2008 Link to this post

    Hi,

    I am looking at creating the columns dynamically and one of the column should be link column. How do we create link button type column in rad grid view? Please help.
  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 12 Aug 2008 Link to this post

    Hello Santhosh Kumar,

    Thank you for writing.

    Currently, RadGridView has no build-in hyperlink column type. Nevertheless, you could format text column to look as hyperlink and catch click event to process it. Please review the code-block below as example:
    Font font;   
    this.radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting);   
    this.radGridView1.CellClick += new GridViewCellEventHandler(radGridView1_CellClick);   
    this.radGridView1.DataSource = table;   
    this.radGridView1.Columns["Name"].ReadOnly = true;   
       
    void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)   
    {   
        if (e.CellElement is GridDataCellElement)   
        {   
            if (((GridViewDataColumn)e.CellElement.ColumnInfo).DataField == "Name")   
            {   
                e.CellElement.Font = font;   
                e.CellElement.ForeColor = Color.Blue;   
            }   
        }   
     
    void radGridView1_CellClick(object sender, GridViewCellEventArgs e)   
    {   
        if (e.ColumnIndex == 1 && e.RowIndex > 0)   
        {   
            Process.Start("http://www.google.com");   
        }   

    If you have other questions, do not hesitate to contact me again.

    All the best,
    Martin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Neeraj
    Neeraj avatar
    1 posts
    Member since:
    Jun 2012

    Posted 10 Dec 2011 Link to this post

    Hai ,
    In the below code the cell formating event is firing continuously and it is not coming out of that event.I have generated this event from the events tab of radgridview.can you please help me out to solve this problem.
  4. Nikolay
    Admin
    Nikolay avatar
    1805 posts

    Posted 15 Dec 2011 Link to this post

    Hello Neeraj,

    The CellFormatting event is fired for each cell when it needs to (re)paint itself. So, it could be compared to the Paint event. That said, it is normal not be to able to come out of that event. If you debug and this is an issue for you, please put your break point somewhere outside that event and break directly there, thus avoiding the CellFormatting event.

    You can read more information about our formatting events in this article.

    I hope this helps.

    Greetings,
    Nikolay
    the Telerik team

    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Back to Top