Reputation: 63
If the user does not have authorization, I want to show the price with a special character instead of a numeric.
I can change the formattype and formatstring in the code block below, but when I try to get the formatstring of the changed column. colPRICE.DisplayFormat.GetFormatString()
is equal to {0}
, {0}
accepts only a numeric value. How can I squash {0}
?
colPRICE.DisplayFormat.FormatType = FormatType.Custom;
colPRICE.DisplayFormat.FormatString = "";
var formatStringPrice = colPRICE.DisplayFormat.GetFormatString();
for (int i = 0; i < gridView1.RowCount; i++)
{
gridView1.SetRowCellValue(i, "PRICE", "****");
}
Upvotes: 0
Views: 299
Reputation: 5890
I would leave the formatting as is and handle CustomDrawCell event for the GridView.
Something like this:
private void gridView1_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
{
if (!DoesUserHaveAuth())
{
e.DisplayText = "******";
}
}
Upvotes: 1