Home Forums WinForms controls Xceed Grid for WinForms Problem assigning value to cell in insertation row.

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

    I am receiving the following error when I try to assign a value to a cell in an insertation row.

    An attempt was made to set the value of the cell whose parent InsertationRow does not have an underlying DataRow.

    I am trying to trap for a particular keystroke. If it occurs, then populate the current cell with a value from the same column but a pervious record that is stored in a value row. I am trying to give the user a quick way to duplicate records with a simple keystroke.

        private void insertionRow1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)

        {

            if (e.KeyCode == Keys.Multiply)

            {

                try

                {

                    int currentCol = gridControl1.CurrentColumn.Index;

                   

                    gridControl1.CurrentCell.Value = historyRow.Cells[currentCol].Value.ToString(); 

                }

                catch (InvalidOperationException exception)

                {

                    MessageBox.Show(exception.Message);

                }

     

            }

        }

    Any ideas.

    Thanks.

    Imported from legacy forums. Posted by JeffB (had 526 views)

    User (Old forums)
    Member
    Post count: 23064

    You should do this on the editor that is editing the InsertionCell as the user types something.

    e.g.:

    private void Form1_Load( object sender, EventArgs e )

    {

        foreach( InsertionCell cell in insertionRow1.Cells )

        {

            cell.CellEditorManager.ActivatingControl +=

    new CellEditorEventHandler(CellEditorManager_ActivatingControl);

            cell.CellEditorManager.DeactivatingControl +=

    new CellEditorEventHandler( CellEditorManager_DeactivatingControl );

        }

    }

     

    void CellEditorManager_ActivatingControl( object sender, CellEditorEventArgs e )

    {

        ( ( WinTextBox )e.Control ).TextBoxArea.KeyUp += new KeyEventHandler( TextBoxArea_KeyUp );

    }

    void TextBoxArea_KeyUp( object sender, KeyEventArgs e )

    {

        if( e.KeyCode == Keys.Multiply )

        {

            ( ( TextBoxArea )sender ).Text = “some text”;

            ( ( TextBoxArea )sender ).SelectAll();

        }

    }

    void CellEditorManager_DeactivatingControl( object sender, CellEditorEventArgs e )

    {

        ( ( WinTextBox )e.Control ).TextBoxArea.KeyUp -= new KeyEventHandler( TextBoxArea_KeyUp );

    }

     

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

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