i m workingon the project based on datagrid , i wan to bold the selected cell,
i hav used the code
C1.Win.C1TrueDBGrid.Style s = new C1.Win.C1TrueDBGrid.Style();
Font newFont;
newFont = new Font(s.Font, FontStyle.Bold);
s.Font = newFont;
dgSheet.AddCellStyle(C1.Win.C1TrueDBGrid.CellStyleFlag.NormalCell, s);
dgSheet.UpdateData();
but is not working properly , actually it bold every cell after selection
plz help me in correcting the code....
anamika
Change in font
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Niradhip ChakrabortyRank #428 · 5.8K pointsPosted Apr 23, 2008, 2:10 PM EDT
For DataGrid Row customization, a common approach is using the
"ItemDataBound" or "ItemCreated" event( GridView has "RowDataBound" and
"RowCreated" event). You can get the reference to database column
fields(pass through databinding) and change the certain property on Row (or
individual cells) in it. Here is a simple example that change the row's
Font-bold based on a column value:
protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs
e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
DataRowView drv = (DataRowView)e.Item.DataItem;
long id = (long)drv[0];
if (id > 3) e.Item.Font.Bold = true;
}
}
refer this code please.
anamika agrawal12 pointsPosted Apr 23, 2008, 9:57 PM EDT
i m beginner ...so kindly help me.......