Hi,
Please provide a code snippet to customize the appearance of the GridViewHyperlinkColumn cells. I'm trying to define the state of a cell based on the help topic at GridViewHyperlinkColumn Appearance.
Please provide a code snippet to customize the appearance of the GridViewHyperlinkColumn cells. I'm trying to define the state of a cell based on the help topic at GridViewHyperlinkColumn Appearance.
3 Answers, 1 is accepted
0
Todd
Top achievements
Rank 1
answered on 26 Mar 2015, 11:55 AM
I've found a workaround at HTML-like Text Formatting. The stylizing piece of code should basically be placed within the GridView CellFormatting event handler:
private
void
radGridView1_CellFormatting(
object
sender, CellFormattingEventArgs e)
{
if
(e.CellElement
is
GridHyperlinkCellElement)
{
e.CellElement.Text = String.Format(
"<html><color=0,0,255>{0}"
, e.CellElement.Text);
}
}
0
Hello Todd,
Thank you for writing.
Indeed, the CellFormatting event is used to add formatting to grid data cells. Here is a sample code snippet demonstrating how to customize the GridHyperlinkCellElement's style:
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Dess
Telerik
Thank you for writing.
Indeed, the CellFormatting event is used to add formatting to grid data cells. Here is a sample code snippet demonstrating how to customize the GridHyperlinkCellElement's style:
public
Form1()
{
InitializeComponent();
GridViewHyperlinkColumn column =
new
GridViewHyperlinkColumn();
column.Name =
"Hyperlink column"
;
this
.radGridView1.Columns.Add(column);
this
.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this
.radGridView1.Rows.Add(
"http://www.telerik.com"
);
this
.radGridView1.Rows.Add(
"http://www.microsoft.com"
);
this
.radGridView1.Rows.Add(
"http://www.google.com"
);
this
.radGridView1.Rows.Add(
"http://www.cnn.com"
);
this
.radGridView1.Rows.Add(
"http://www.bbc.com"
);
this
.radGridView1.Rows.Add(
"http://www.telerikwatch.com/"
);
this
.radGridView1.Rows.Add(
"http://www.wikipedia.com"
);
}
private
void
radGridView1_CellFormatting(
object
sender, CellFormattingEventArgs e)
{
GridHyperlinkCellElement hyperlinkCell = e.CellElement
as
GridHyperlinkCellElement;
if
(hyperlinkCell !=
null
)
{
GridViewHyperlinkCellInfo cellInfo = e.Row.Cells[e.Column.Name]
as
GridViewHyperlinkCellInfo;
if
(cellInfo.Visited)
{
hyperlinkCell.ContentElement.Text = String.Format(
"<html><color=0,0,255>{0}"
, e.CellElement.Text);
}
else
{
hyperlinkCell.ContentElement.Text = String.Format(
"<html><color=yellow>{0}"
, e.CellElement.Text);
}
}
}
I hope this information helps. Should you have further questions, I would be glad to help.
Dess
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0
Todd
Top achievements
Rank 1
answered on 08 Apr 2015, 11:43 AM
Thanks, Dess! Here's the more complete reference of the HTML tags for formatting that I've found: