Visual Studio .NET - Enter the from textbox text to dispaly datagridview

Asked By Dharma K on 05-Jul-08 03:25 AM
How to display Textbox(or)label  valu to Datagridview1 in vb.net Windows application

Reply - alice johnson replied to Dharma K on 05-Jul-08 03:56 AM

linking textbox to cell in a datagridview cell:
Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e
As System.Windows.Forms.DataGridViewRowPostPaintEvent Args) Handles
DataGridView1.RowPostPaint
If Not IsDBNull(DataGridView1.CurrentRow.Cells(17).Value) Then
TextBox1.Text = DataGridView1.CurrentRow.Cells(17).Value
End If
End Sub

try this.... - Vasanthakumar D replied to Dharma K on 05-Jul-08 04:20 AM

Hi,

if you want to set the  value for datagridview1 from textbox , use the below code

DatagridView[RowNo, CellNo].Value = Textbox.Text;

See this - Sagar P replied to Dharma K on 05-Jul-08 04:34 AM

If you want to assign text box's value to gridview then just try it like;

int RowNo=0;

int ColNo=0;

GridView1[RowNo, ColNo].Value = Tebox1.Text;

It will add text box value into grid view's 1st row 1st col.

For label just try this one;

GridView1[RowNo, ColNo].Value = Label1.Text;

Best Luck!!!!!!!!!!!!!!
Sujit.

Re : Enter the from textbox text to dispaly datagridview - Ashutosh Dhok replied to Dharma K on 05-Jul-08 06:38 AM

Hi Dharma,

            Firstly you have to assign dataset, datatable which have rows to dataview.
     So that the rows will generate  for the gridview. After that assign value of Textbox or Label to
     gridview's perticular cell of any row.     


 GridView1[RowNumber, ColNumber].Value = Tebox1.Text;

 Or

 GridView1[RowNumber, ColNumber].Value = Label1.Tex

Regards
Ashutosh

Thank u Vasanth...Thanks to all - Dharma K replied to Vasanthakumar D on 05-Jul-08 08:08 AM

It's very use full.............

Thanks Sujit - Dharma K replied to Sagar P on 05-Jul-08 08:08 AM
Thanks Sujit