I have an UltraGrid which is bound to a DataTable with two columns (Key, Value). I have added 10 rows into the DataTable, and now the 11th row has a URL in the Value column. The URL value gets added fine, but it doesn’t work like a hyperlink. To make it work as a hyperlink, how do I need to add this row into the UltraGrid?
My code:
DataTable dt = new DataTable();
dt.Columns.Add("Key", typeof(string));
dt.Columns.Add("Value", typeof(string));
ultraGrid.DataSource = dt;
foreach (KeyValuePair<string, string> kvp in dictionary)
{
dt.Rows.Add(kvp.Key, kvp.Value);
}
// Adding the row which has the URL value.
string url = "SomeURL";
Uri hyperLink = new Uri(url);
dt.Rows.Add("Click this", hyperLink);
While the answer given by U1199880 point to a partially correct solution there is a problem applying that style to the whole column. Every cell in the column will be treated as a link.
Instead you need to intercept the
InitializeRowevent and check if the current cell of the current row is a valid URI. Then change the cell Style property to the ColumnStyle.URL