Home Forums WinForms controls Xceed Grid for WinForms Checkbox value/state in DetailGrid

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

    I am using Xceed Grid For .Net. I have a master grid which has a child detailgrid with a few columns.

    The child detailgrid’s first column is set to use CheckBoxEditor / CheckBoxViewer, such that detailgrid rows can be selected/unselected using the checkbox. I want certain method to be called when the checkbox is checked/unchecked.

    I am having tough time finding the correct event handler that gets initiated when checkbox value is changed on a detail row in a datagrid.

    I tried using ‘ValueChanged’ but it doesn’t seem to work properly.

    If you can help me with that will be great.
    Thanks

    Imported from legacy forums. Posted by S (had 2421 views)

    User (Old forums)
    Member
    Post count: 23064

    btw..just to post some more info .. I got the check box checked/unchecked event handler to work.. by doing this ..while adding rows to Detail grid..

    DataRow parentRow = gridControl1.DataRows[_key];
    if(parentRow != null)
    {
    parentRow.DetailGrids[0].DataRows[0].Cells[“chkDetailRow”].CellEditorControl;
    parentRow.DetailGrids[0].Columns[“chkDetailRow”].CellEditorManager.ActivatingControl += new CellEditorEventHandler(CellEditorManager_ActivatingControl);
    parentRow.DetailGrids[0].Columns[“chkDetailRow”].CellEditorManager.DeactivatingControl += new CellEditorEventHandler(CellEditorManager_DeactivatingControl);
    }

    private void CellEditorManager_ActivatingControl(object sender, Xceed.Grid.Editors.CellEditorEventArgs e)
    {
    ((Xceed.Editors.WinCheckBox)e.Control).CheckedChanged += new EventHandler(Form1_CheckedChanged);

    }

    private void CellEditorManager_DeactivatingControl(object sender, Xceed.Grid.Editors.CellEditorEventArgs e)
    {

    ((Xceed.Editors.WinCheckBox)e.Control).CheckedChanged -= new EventHandler(Form1_CheckedChanged);

    }

    private void Form1_CheckedChanged(object sender, EventArgs e)
    {
    if (sender != null)
    {
    //some code here…
    }
    }

    but the problem of changing the background color of a seperate column based on the state of checkbox (checked/unchecked) still remains.. I don’t know how to access the current row that is being checked and its columns…If I have to set current row’s 3rd column’s background to Green, how would I do that?
    If anyone has any ideas please let me know..

    Imported from legacy forums. Posted by S (had 347 views)

    Xceed Support
    Member
    Post count: 5658

    You have 2 possibilities here:

    1- You could use the “CurrentRow” item from the gridControl1. This reference also applies inside a Detail grid.

    <code>
    ( ( Xceed.Grid.DataRow )gridControl1.CurrentRow ).Cells[ 2 ].BackColor = Color.Green;
    </code>

    2- You could use the “ParentRow” reference of the e.Cell inside your ActivatingControl event.

    <code>
    void CellEditorManager_ActivatingControl( object sender, CellEditorEventArgs e )
    {
    ( ( Xceed.Grid.DataRow )e.Cell.ParentRow ).Cells[ 2 ].BackColor = Color.Green;
    }
    </code>

    Imported from legacy forums. Posted by CharlesB (had 3415 views)

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