This is a migrated thread and some comments may be shown as answers.

Link Button Type Column in Grid View

3 Answers 152 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Santhosh Kumar
Top achievements
Rank 1
Santhosh Kumar asked on 12 Aug 2008, 02:33 AM
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.

3 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 12 Aug 2008, 01:33 PM
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.
0
Neeraj
Top achievements
Rank 1
answered on 10 Dec 2011, 07:05 AM
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.
0
Nikolay
Telerik team
answered on 15 Dec 2011, 09:40 AM
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.

Tags
GridView
Asked by
Santhosh Kumar
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Neeraj
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or