Hi, I have a WinForm with a datagrid in it. Inside the data grid, I have one column which is DataGridViewLinkColumn in which I will have hyperlink to allow users to navigate to website based on the URL constructed.
I have a few questions regarding this as I am not familiar with WinForm. Below are my codes:
foreach (DataGridViewRow row in dgvCustomer.Rows)
{
foreach (var cell in row.Cells)
{
DataGridViewLinkCell linkCell = cell as DataGridViewLinkCell;
if (linkCell.Value.ToString()== "0")
{
linkCell.UseColumnTextForLinkValue = true;
linkCell.Value = "Use Customer Standard";
}
}
}
I have successfully populate all the data into gridview.
From the above codes, I will access the gridview row by row and I tried to change the behaviour and value of the particular cell which fulfill certain condition like above.
This is due to although this is DataGridViewLinkColumn, under certain condition, I want to remove the hyperlink behaviour and just display the value as plain text.
I always getting null exception at the linkCell variable, at the IF statement.
May I know how can I achieve this?
What I have tried:
1. Search for article on internet but to no avail.
2. Tried to make use of the intellisense in codes(putting the .(dot)) to see if there is any suggestion by VS but found none.