The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi. I’m using the GDBG with several columns, one is set to type “ColorEdit”. I want to display only the colour in the cell and not the name or any other text. It mostly works but with two exceptions.
1) In the PrepareViewStyleInfo event I have...
if (e.RowIndex > 0) { if (e.ColIndex == COLOUR_COLUMN) e.Style.TextColor = Color.FromName(e.Style.Text); }
... which hides the text. However, after the colour is changed but before the user leaves the row the name of the colour is visible. Is there an earlier event I can use that fires immediately after the colour is changed?
2) But more importantly, even though it is hidden the text can still be edited/corrupted by the user. How do I prevent this? (I only want to accept button clicks for this column.)
RCRajadurai 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;