Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I use devexpress gridControl how can I fill first row in gridControl by code then Fill out the other rows by datatable? or how can add data to specific row. i read documentation for devexpress but no result

What I have tried:

https://e.top4top.io/p_1696kvomr1.png[^]
Posted
Updated 23-Aug-20 19:32pm

1 solution

Key here would be below in sequence:
1. Fill the grid with datatable first
2. Add a new row at index 0 as per need as second step

Step 2, example:
C#
Random rand = new Random();  
DataTable dt = gridControl1.DataSource as DataTable;  
DataRow newRow = dt.NewRow();  
newRow["ID"] = rand.Next(0, 100);  
newRow["Info"] = "Info" + (gridView1.RowCount - 1).ToString();  
dt.Rows.InsertAt(newRow, 0);

References:
Q524021 - GridView - How to add a new row to a specific position | DevExpress Support[^]
Add and Remove Rows | WinForms Controls | DevExpress Documentation[^]
GridView.AddNewRow() Method | WinForms Controls | DevExpress Documentation[^]

BTW, DevExpress has good examples, support and community - I would always look there first thing.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900