hi,i have a three columns in empty datagridview to get a input from user.i had a doubt to create a new row after entering the values in those previous cells

Recommended Answers

All 4 Replies

Dim dt as new datatable
' Code to add columns to table
        dt.Columns.Add("A", Type.GetType("System.String"))
        dt.Columns.Add("B", Type.GetType("System.String"))
        dt.Columns.Add("C", Type.GetType("System.String"))
'Binding the rows to gridview
        DataGridView1.DataSource = dt
' Code to add new row
        Dim dr As DataRow
        dr = dt.NewRow
        dt.Rows.Add(dr)

Shorten it down like this:

dim dr As New DataRow("Your row's name")
dt.Rows.Add(dr)

Hi Eternal Newbie,
Are you sure we can Declare and assign datarow like what you shown above?

I'm replacing the part to create a new row. Well, it's working if he's already had a table in his project.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.