Home Forums WinForms controls Xceed Grid for WinForms Automatically add a new row

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

    Hi!

     We are currently redeveloping an application in .NET and Xceed components. The current version of the application adds new lines to a grid when the user presses the down arrow on the last line of data.

     Any suggestions on how I can make it do this in Xceed Grid?

     I’ve tried a few things, but they don’t seem to work as well as hoped.

     Any help would be most appreciated!

     

    Ben

    Imported from legacy forums. Posted by Ben (had 493 views)

    User (Old forums)
    Member
    Post count: 23064

    You can try using the KeyUp event on the DataRowTemplate, and do something like the following in the event handler :

    private void Form1_Load( object sender, EventArgs e )

    {

        dataRowTemplate1.KeyUp +=

    new KeyEventHandler( dataRowTemplate1_KeyUp );

    }

    private bool secondEnter = false;

    void dataRowTemplate1_KeyUp( object sender, KeyEventArgs e )

    {

        if( e.KeyCode == Keys.Down )

        {

            Xceed.Grid.

    DataRow row = sender as Xceed.Grid.DataRow;

            if( row != null )

            {

                ReadOnlyDataRowList rowList = gridControl1.GetSortedDataRows( true );

                if( rowList.IndexOf( row ) == rowList.Count – 1 && secondEnter )

                {

                    row = gridControl1.DataRows.AddNew();

                    row.EndEdit();

                    gridControl1.MoveCurrentRow(

    VerticalDirection.Down );

                    gridControl1.SelectedRows.Clear();

                    gridControl1.SelectedRows.Add( row );

                }

                else if( rowList.IndexOf( row ) == rowList.Count – 1 )

                    secondEnter =

    true;

                else

                    secondEnter =

    false;

            }

        }

    }

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

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