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

    Hi –

    I started using the Xceed grid a few weeks ago and I now want to adjust the default behaviour of the CheckBox columns in 2 ways:

    1) I want the checkbox value to be committed to the datasource as soon as it is checked.  This was solved a few days ago in another thread on here by hooking into the WinCheckBox Checked event and then running LeaveEdit(true) on the DataCell once raised.

    This was working fine but I noticed another issue (maybe a bug?) that when a cell is clipped, even if the checkbox is still showing, when you click on the checkbox, the cell gets refocused to the middle of the grid (something similar to running BringIntoView()) but the checkbox does NOT get checked.  This is not an issue when the whole grid can be shown in one go, but as soon as it becomes scrollable, the checkboxes only become checked on their first click when the cell they are in is fully visible.  I can include screenshots if this is description is unclear.  Given this:

    2) I want the checkbox to respond to the user’s click even when the cell is not fully visible (I don’t care that it gets refocused to the center of the grid, but I do need it’s state to have been changed to a checked/unchecked state based on the user’s click).  Ignoring the fact that the events do not get cleaned up, I tried something like this:

    private void DataSourceChangedEventHandler(object sender, EventArgs e)
    {
                 foreach (DataCell cell in parameterGrid.DataRowTemplate.Cells)
                {
                        cell.MouseLeave += CellMouseLeave;
                        cell.MouseEnter += CellMouseEnter;
                        cell.EditEntered += CellEnterEdit;
                        cell.EditLeft += CellEditLeft;
                        if (cell.CellEditorManager is CheckBoxEditor)
                        {
                            cell.CellEditorManager.ActivatingControl += cb_ActivatingControl;
                            cell.CellEditorManager.DeactivatingControl += cb_DeactivatingControl;
                            cell.MouseDown += cell_MouseDown;
                        }
                    }

     void cell_MouseDown(object sender, MouseEventArgs e)
            {
                DataCell dc = sender as DataCell;
                dc.CellEditorControl.MouseDown += WinCheckBox_MouseDown;
            }

    void WinCheckBox_MouseDown(object sender, MouseEventArgs e)
            {
                WinCheckBox checkBox = sender as WinCheckBox;
                if (checkBox != null)
                {
                    checkBox.Checked = !checkBox.Checked;
                }

            } 

    This solution worked for the limited case where the cell was clipped and I was happy but when the cell isn’t clipped I get very strange behaviour where I guess the internal event is checking the checkbox as well as mine so it alternates and only when my mouse leaves the cell does the correct value appear in the checkbox and I think my solution to the first issue is also clashing somehow.  My CellEditorDisplayConditions are set to MouseOverCell but these problems are only a big issue for my boolean columns.

    Would the solution be to make these cells ReadOnly and just manage the source value updates manually – how would I go about doing that?

    Otherwise, can anyone help me solve this problem?  It is a big issue for my application 🙁 

    Thanks! 

    Imported from legacy forums. Posted by James (had 1284 views)

    User (Old forums)
    Member
    Post count: 23064

    Been playing around with this today and it is still puzzling me why the grid treats cells that are not fully in view differently to those that are.  Is this a bug?  When I click on a checkbox who’s cell is fully in view, it gets toggled successfully.  If I click on a checkbox who’s cell is part-clipped by the grid boundry, it gets centered but NOT toggled?

    I have attached a click event handler to the check boxes of each cell and I can toggle the checkbox when this gets handle raised (both when fully in view and not) but now I cannot differentiate these two states – is there anyway to find out if a cell is clipped by the edge of the grid?  

    If I could do this my code would look something like this (Parent:

     void checkbox_Click(object sender, EventArgs e) {
    if (((WinCheckBox)sender).ParentCell.IsClippedByGridBoundry)
    ((WinCheckBox)sender).Checked = !((WinCheckBox)sender).Checked;

    The only issue is I cannot find any differenciating properties between a clipped cell and a non-clipped cell.

    Can anyone help? 

    Imported from legacy forums. Posted by James (had 447 views)

    User (Old forums)
    Member
    Post count: 23064

    Had another think about this, solved it using the FirstVisibleColumnChanged event on the grid:

     

            private bool mHasGridMoved;

            private void FirstVisibleColumnChanged(object sender, EventArgs e)

            {

                mHasGridMoved = true;

            }

            private void CheckBoxCellMouseExit(object sender, EventArgs e)

            {

                DataCell dc = sender as DataCell;

                if (dc != null)

                {

                    dc.CellEditorControl.MouseDown -= WinCheckBox_MouseDown;

                    mHasGridMoved = false;

                }

                

            }

            private void CheckBoxCellMouseEnter(object sender, EventArgs e)

            {

                DataCell dc = sender as DataCell;

                if (dc != null)

                {

                    dc.CellEditorControl.MouseDown += WinCheckBox_MouseDown;

                    mHasGridMoved = false;

                }

                

            }

            private void WinCheckBox_MouseDown(object sender, MouseEventArgs e)

            {

                WinCheckBox checkBox = sender as WinCheckBox;

                if (checkBox != null && mHasGridMoved)

                {

                    checkBox.Checked = !checkBox.Checked;

                }

            }

     

    Imported from legacy forums. Posted by James (had 918 views)

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