Home Forums WinForms controls Xceed Grid for WinForms How do I a button to a cell…

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

    …or to a textbox first and then adding that to a cell that is not editable but should allow for me to click on it to fire off an event.  When the cell is editable I can click the button and see a visible response but no event is fired.

    I tried this, with the attached events not doing anything (even when the cell was editable):

    WinTextBox onHandBox = new WinTextBox(EnhancedBorderStyle.None);
    WinButton reconcileOnHandButton = new WinButton(new ButtonType(ButtonBackgroundImageType.Standard, ButtonImageType.Edit));
    reconcileOnHandButton.Width = 25;
    reconcileOnHandButton.Enabled = true;
    reconcileOnHandButton.Click += new EventHandler(ReconcileMaterial_Click);
    onHandBox.SideButtons.Add(reconcileOnHandButton);
    onHandBox.SideButtons[0].CanSelect = true;
    onHandBox.SideButtons[0].Click += new EventHandler(ReconcileMaterial_Click);

    TextEditor onHandEditor = new TextEditor(onHandBox);
    TextViewer onHandViewer = new TextViewer(onHandBox);
    row.Cells[1].CellEditorManager = onHandEditor;
    row.Cells[1].CellViewerManager = onHandViewer;

    Imported from legacy forums. Posted by Willie (had 904 views)

    User (Old forums)
    Member
    Post count: 23064

    Anyone out there?

    Imported from legacy forums. Posted by Willie (had 414 views)

    User (Old forums)
    Member
    Post count: 23064

    You need to use the ActivatingControl event to get access to events on controls in cells in the grid when the column is not read only, or use the Click event on the cell when the Column is read only.

    e.g.:

    private void Form1_Load( object sender, EventArgs e )

    {

        WinButton saveBtn = new WinButton( “Save” );

        saveBtn.ButtonType =

    new ButtonType( ButtonBackgroundImageType.SpinUp, ButtonImageType.SpinUp );

        gridControl1.Columns[

    “column1” ].CellEditorManager = new CellEditorManager( saveBtn, “”, true, true );

        gridControl1.Columns[

    “column1” ].CellViewerManager = new CellViewerManager( saveBtn, “” );

    //if column not readonly

        gridControl1.Columns[ “column1” ].CellEditorManager.ActivatingControl += new CellEditorEventHandler( CellEditorManager_ActivatingControl );

        gridControl1.Columns[ “column1” ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler( CellEditorManager_DeactivatingControl );

    //or if readonly

        gridControl1.Columns[

    “column1” ].ReadOnly = true;

        gridControl1.DataRowTemplate.Cells[

    “column1” ].Click += new EventHandler( Cell_Click );

    }

    void CellEditorManager_ActivatingControl( object sender, CellEditorEventArgs e )

    {

        ( (

    WinButton )e.Control ).Click += new EventHandler( Form1_Click );

    }

    void CellEditorManager_DeactivatingControl( object sender, CellEditorEventArgs e )

    {

        ( (

    WinButton )e.Control ).Click -= new EventHandler( Form1_Click );

    }

    void Form1_Click( object sender, EventArgs e )

    {

        WinButton button = sender as WinButton;

        if( button != null )

            System.Diagnostics.

    Debug.WriteLine( button.Text );

    }

    void Cell_Click( object sender, EventArgs e )

    {

        System.Diagnostics.

    Debug.WriteLine( “cell click event” );

    }

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

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