Hey guys.... really need your help?
I'm working in VB C# 2010.... I have a windows form application where i want the texts from multiple texboxes to be added to the dataGridView as one row...
can someone please tell me where to start?
Thanks
Hey guys.... really need your help?
I'm working in VB C# 2010.... I have a windows form application where i want the texts from multiple texboxes to be added to the dataGridView as one row...
can someone please tell me where to start?
Thanks
Hi,
As far as I know you have to follow these steps to add values from TextBox to dataGridView:
1- Fisrt of all Create a Data Table (Let's call it MyTable)
DataTable MyTable = new DataTable();
2- You are right! Now we need to create Column for our Tbale ( using DataColumn)
DataColumn clm = new DataColumn("Column1");
DataColumn clm2 = new DataColumn("Column2");
3- Now Add the Columns to the Table
MyTable.Columns.Add(clm);
MyTable.Columns.Add(clm);
4- Time to Create Rows,
DataRow rd = MyTable.NewRow();
5- Populate the rd with text value
rd[0] = textBox1.Text;
rd[1] = textBox2.Text;
6- Add Rows to the MyTable
MyTable.Rows.Add(rd);
7- Finally populate the dataGridView object with MyTable
dataGridView1.DataSource = MyTable;
Hopes this help you,
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.