Home Forums WinForms controls Xceed Grid for WinForms format data using mask characters with bound data Reply To: format data using mask characters with bound data

User (Old forums)
Member
Post count: 23064

Thanks for your help. However, I still cannot achieve what I intend to have (ie. format 12345.HK) on my grid. I have:

gridControl.Columns[column].CellEditorManager = new Xceed.Grid.Editors.TextEditor(“>#####.@@”);

gridControl.Columns[column].CellViewerManager = new Xceed.Grid.Viewers.TextViewer(“>#####&@@”);

I tried to handle the GettingControlValue event of the CellEditorManager, (I parse the cell value and place the dot between the first 5 digits and the last 2 letters) and I can successfully add the data with the intended format onto my grid with no problem. However, problem occurs with filling the grid initially with bound data from database. I got this error:

System.InvalidOperationException occurred
  Message=”The length of the raw text exceeds the length of the mask.”
  Source=”Xceed.Editors”
  StackTrace:
       at Xceed.Editors.TextBoxArea.ValidateTextCore(String editText, Boolean fullValidation)

because my data in the database is already in the format 12345.HK (with the dot). While the CellEditorManager expects input to have format 12345HK (without the dot), and it generates the dot on the grid automatically upon editing. I guess that it is what caused the problem?

I’m still puzzling on how to solve this problem. Can anyone give me suggestion please?

 Thanks in advance.

Imported from legacy forums. Posted by Sop (had 784 views)