RC
Rajadurai C
Syncfusion Team
April 23, 2009 02:25 PM UTC
Hi Pedro,
Thanks for your interest in Syncfusion products.
1) To hide the text from the user, you can make use of TextMargins property. Please refer to the following code which hides text from the user.
ColorConverter cc = new ColorConverter();
void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex == 1)
{
int height = this.gridDataBoundGrid1.Model.RowHeights[e.RowIndex];
e.Style.CellType = "ColorEdit";
e.Style.BackColor = (Color)cc.ConvertFromString(e.Style.CellValue.ToString());
e.Style.TextMargins.Top = height / 2;
e.Style.TextMargins.Bottom = height / 2;
}
}
2) If you want to prevent the users from editing the textbox part of ColorEdit cell, set the renderer' EditPart' Enabled property to false. Please refer to the following code.
GridDropDownColorUICellRenderer rend = this.gridDataBoundGrid1.CellRenderers["ColorEdit"] as GridDropDownColorUICellRenderer;
rend.EditPart.Enabled = false;
Regards,
Rajadurai