We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Mask Edit a whole column and color codes

2 questions - I would like to mask edit column 7 with "9999-99-99" - the code below didn''t work - what did i do wrong? Also where are the color definitions for Color.FromArgb(255, 255, 255) - I want to what integers represent colors such as yellow? Private Sub Datagrid10_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs) Handles Datagrid10.PrepareViewStyleInfo Dim grid As GridDataBoundGrid = sender If Not (grid Is Nothing) AndAlso e.RowIndex > grid.Model.Rows.HeaderCount AndAlso e.ColIndex > grid.Model.Cols.HeaderCount Then If grid.IsShowCurrentRow(e.RowIndex) AndAlso Not grid.CurrentCell.HasCurrentCellAt(e.RowIndex, e.ColIndex) Then e.Style.BackColor = SystemColors.Highlight e.Style.TextColor = SystemColors.HighlightText Else Dim rs As GridBoundRecordState = grid.Binder.GetRecordStateAtRowIndex(e.RowIndex) If rs.Position Mod 2 = 0 Then e.Style.BackColor = Color.FromArgb(255, 255, 255) Else e.Style.BackColor = Color.FromArgb(219, 226, 242) End If End If End If If e.ColIndex = 7 And e.RowIndex = 1 Then ''e.Style.Font.Italic = True e.Style.Font.Bold = True ''e.Style.Font.Orientation = 270 e.Style.TextColor = Color.Red End If If e.ColIndex = 7 And e.RowIndex > 1 Then e.Style.MaskEdit.Mask = "9999-99-99" End If End Sub ''gridDataBoundGrid1_PrepareViewStyleInfo

1 Reply

AD Administrator Syncfusion Team October 12, 2004 05:13 AM UTC

There is no code that sets e.Style.CellType = "MaskEdit" in the code you listed. Are you setting this somewhere else? I would first try setting e.Style.CellType = "MaskEdit" in PrepareViewStyleinfo to see if that is what is missing. Or, since you want to set the whole column to be this celltype, you can just directly set it once in formload using either grid.GridBoundColumns(6).StyleInfo or grid.Binder.InternalCOlumns(6).StyleInfo to set both the CellType property and the Mask proeprty for this column. (Use GridBoundColumns if you have explicitly added them or you Binder.InternalCOlumns if you have not explicitly added gridboundcolumns.) If neither of the other suggestions allow things to work, there are some style setting that do not work when being set within PrepareViewStyleInfo. (ReadOnly is one such setting.) I am not sure if trying to set MaskEdit is one of these or not. But if you are setting style.CellType = "MaskEdit" in your code somehow, then celltype = "MaskEdit" may be like ReadOnly in that it needs to be set earlier than PrepareViewStyleInfo. In these case, you can use grid.Model.QueryCellInfo to set these style properties. See this KB for sample code. http://www.syncfusion.com/Support/article.aspx?id=10351

Live Chat Icon For mobile
Up arrow icon