Home Forums WinForms controls Xceed Grid for WinForms Xceed Grid cell turns Red X when an integer field is changed to view as checkbox viewer

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17022 |

    XLT_RUN is an integer field 

    LTdataGrid.Columns(“XLT_RUN”).CellViewerManager = New Xceed.Grid.Viewers.CheckBoxViewer()

    Imported from legacy forums. Posted by Prabha (had 1358 views)

    User (Old forums)
    Member
    Post count: 23064

    The WinCheckBox editor (which is the control underneath the CheckBoxViewer) expects a boolean value, not an integer, so it throws an exception that is swallowed by the grid, and the grid displays a red X instead.  What you need to do is handle the SettingControlValue event on the CheckBoxViewer, and convert the int value to boolean value (or a CheckState value to be precise) so the viewer can display itself correctly.

    e.g.:

        private void Form1_Load( object sender, EventArgs e )
        {
          gridControl1.Columns[ IntColumn ].CellViewerManager = new CheckBoxViewer();
          gridControl1.Columns[ IntColumn ].CellViewerManager.SettingControlValue += new CellViewerEventHandler(CellViewerManager_SettingControlValue);
        } 

        void CellViewerManager_SettingControlValue( object sender, CellViewerEventArgs e )
        {
          if( ( int )e.Cell.Value == 0 )
          {
            ( ( WinCheckBox )e.Control ).CheckState = CheckState.Unchecked;
          }
          else if( ( int )e.Cell.Value == 1 )
          {
            ( ( WinCheckBox )e.Control ).CheckState = CheckState.Checked;
          }
          else
          {
            ( ( WinCheckBox )e.Control ).CheckState = CheckState.Indeterminate;
          }
        }

    Imported from legacy forums. Posted by André (had 2051 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.