Home Forums WinForms controls Xceed Grid for WinForms CellEditor and CellViewer Heights

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

    Hi,

    I’m having a bit of trouble with my datagrid at the moment. I’ve designed a working CellViewer and CellEditor for a particular column in my grid. However, they have differing heights. Basically, the viewer shows the company name, and the editor shows the company name as well as the phone and fax numbers. There isn’t any actual editing, but works great by showing the phone\fax for the currently selected company. (I’ve got single click edit turned on).

    However, if i dont’ change any heights of rows when i enter edit mode, the row clips off the bottom of the edit control (which is about 15-20 pixels taller). I’ve tried doing things like, in the beginning edit event, changing the height of the current row to the height of the celleditor control, and on the ending edit event changing it back however it doesn’t seem to work properly. After each leaving edit, the edit control size seems to shink by a few pixels. So it works fine the first time, but the 2nd time it is about 2 pixels too short, and then the 3rd time its 4 pixels too short and so on.

    Is there a property or work around to get this to work? Cause it looks really great when it is working 🙂

    Thanks!

    Ben

    Imported from legacy forums. Posted by apollo (had 2696 views)

    User (Old forums)
    Member
    Post count: 23064

    When implementing the ICellEditor-interface, your InPlace-property should return false. This means that the grid won’t automatically give the control the size of the gridcell. It does mean that the celleditor will be moved outside the gridcell-rectangle (above or below).
    You could also let InPlace return true, but in your ActivateControl-method, you create a Panel (or a different control) and place it above the grid at the position of the cell.

    Imported from legacy forums. Posted by Tommy (had 246 views)

    User (Old forums)
    Member
    Post count: 23064

    Well,

    I figured it out. I kept going with the line of thinking i was on, and tried this.

    private void dataRowTemplate2_BeginningEdit(object sender, System.ComponentModel.CancelEventArgs e)
    {
    // Get the DataRow that spawned the event.
    Xceed.Grid.DataRow oRow = (Xceed.Grid.DataRow)sender;
    // Set a private class variable to the current height of the row. We can use it to reset the height in the EndingEdit event.
    this.nRowHeight = oRow.Height;
    // 28 is the height of the control i want to use as an Editor
    oRow.Height = 28;
    }

    private void dataRowTemplate2_EndingEdit(object sender, System.ComponentModel.CancelEventArgs e)
    {
    // Get the DataRow that spawned the event.
    Xceed.Grid.DataRow oRow = (Xceed.Grid.DataRow)sender;
    // reset the height using the nRowHeight variable set in the BeginningEdit Method
    oRow.Height = this.nRowHeight;
    }

    Which seems to work well. Looks quite pretty actually 🙂

    Tommy, thanks for your help!

    Regards

    Ben

    Imported from legacy forums. Posted by apollo (had 3781 views)

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