hi everybody, i wish everything is okey? my question is
how i can the value of textbox show on colums in datagridview , my textbox read data from DB ??
I don't get what you mean.
You want add value from textbox to datagrid?
yes that what i want and i want to display it when the form running..
can someone help me please i have a form that conatains a textbox and datagridview
the user enter the value in textbox then i need this value transfer to first cols in datagridview, what i can do, help plz
Is the data grid view bound to a data base or data set?
well you have to add columns first in order to add any value to your grid.
yes its bounded with datasource.
okey i use this code to display the value of text box on the datagrid but when i want to enter value on next col the data diappear, someone have an anser plz???
Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged
For i = 0 To Me.DataGridViewBOQTY2.RowCount - 1 DataGridViewBOQTY2.Rows(i).Cells(0).Value = projectboqtnocalculation.Text Next End Sub
If you are not commiting the changes to the database on insert, then you will just refresh the data - erasing the values inserted on the next insert.
What database are you using?
What methods are you using to connect to the database?
no the value saved to database but when i want to enter the next value the prev one disappear. but its insert to database
i use conectionString and my DB sqlserver
I am trying to wrap my head around what you are wanting...
A) Wanting to insert the value into the first column ( all rows ) then shift the columns right on the next insert
B) Wanting to create a new row with the value in the first column
If you are wanting A, you will have to create a new column for every entry.
If you are wanting B, you will have to create a new row for every entry.
i need A but , how i can do this ??
someone help me please by any idea..
If this is tied to a database, which it is, you will have to create a new column in the database every time you insert a value.
This is not a good thing, considered you could possibly have an infinitely increasing table.
Is it possible you can store the values in rows instead of columns?
yes i can store the values in row , but how ?
Create an new entry in the database, then store the value into the coulmn specified:
If you are doing all the statements by hand, try something like this:
Try Dim con As New System.Data.SqlClient.SqlConnection("connectionStringHere") con.Open() Dim cmd As New System.Data.SqlClient.SqlCommand("INSERT INTO table1(column1) VALUES ('" & TextBox1.Text & "')", con) cmd.ExecuteNonQuery() Catch ex As Exception MsgBox(ex.Message) End Try