Skip to content

Change in font

anamika agrawal

Asked Apr 23, 2008, 2:34 AM EDT2 answers
Share
LinkedInX
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

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Niradhip Chakraborty
    0

    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.

    0
  • 0
    thx for reply of my query but i m sorry that i forget to write that i m using unbound  datagrid....
    i m beginner ...so kindly help me.......
    0