0

I am new to C# and trying to know more by trying to develop simple Windows application. In the application i used the DevExpress GridView. i am trying to add the content of textbox control to DevExpress Unbounded Gridview on button click like this. I tried like this but nothing show up in the GridView.

Private void btn_Add_to_List_Click(object sender, EventArgs e)
    {            
        gridView1.AddNewRow();
    }

private void gridView1_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
    {
        DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
        view.SetRowCellValue(e.RowHandle, view.Columns[0], cBox_ProcessingMaterial.Text.ToString());
        view.SetRowCellValue(e.RowHandle, view.Columns[1], txtBox_Qty_Used.Text.ToString());


    }

This is the form i used

The version of DevExpress i am using is 16.2.4. i have seen the documentation but the only thing i get is for bounded GridView only. please i need help. Thanks!!

1
  • What have you actually tried? Does it work? Not Work? Give an error? Commented May 24, 2017 at 19:00

1 Answer 1

1

When you call AddNewRow it will fire an event - InitNewRow. In there you can initialise the values of the new row.

This appears to be covered in their documentation: https://documentation.devexpress.com/#WindowsForms/DevExpressXtraGridViewsBaseColumnView_InitNewRowtopic

It includes an example, which is:

private void gridView1_InitNewRow(object sender, InitNewRowEventArgs e) {
   DevExpress.XtraGrid.Views.Grid.GridView view = sender as Grid.GridView;
   view.SetRowCellValue(e.RowHandle, view.Columns["PurchaseDate"], DateTime.Today);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.