DataGridView combobox question

This doubt is regarding with datagrid

i HAVE CERTAIN CONTROLS IN MY FORM INCLUDING ONE COMBOBOX CALLED cmbSystem .When i click OK the values i entered will go the datagrid in the same form.But the thing if i wanted to change the value of the system in the datagrid ,i want to do that.For that purpose added a DataGridViewComboBoxColumn.,so that i will dynamically generated at runtime.But the problem is I am not getting in the DataGridViewComboBoxColumn the selected text in the combobox.what can i do for that
.Sorry for my bad english

Private Sub frmCostingInput_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim comboBoxCol As New DataGridViewComboBoxColumn
comboBoxCol.HeaderText = "System"
comboBoxCol.Width = "162"
Me.DataGridView1.Columns.Insert(0, comboBoxCol)

end sub
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

Dim rs As SqlDataAdapter

rs = New SqlDataAdapter("select * from tb_input,con)
Dim ds As DataSet = New DataSet
' fill dataset
rs.Fill(ds, "tb_input")
DataGridView1.DataSource = TESTDATASET
TESTDATASET.DataSource = ds
COMBOBOXCOL.ValueMember = cmbSystem.Text
COMBOBOXCOL.DisplayMember = cmbSystem.Text

end sub


  • seancampbellseancampbell Pennsylvania, USA
    Lets see if I understand this correctly.

    You want to update a database (or some other datasource) with changes that you made to a Row in a DataGridView? In other words, you have a comboBox that populates based on some values. You can then change that comboBox and click "OK" to submit the changes?
  • [color=Red]By using this code i am able to check is numeric.But How can i check for alphabets only [/color]
    Private Sub DataGridView2_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles DataGridView2.CellValidating
    If e.ColumnIndex = 4 then
    If Not IsNumeric(e.FormattedValue) Then
    DataGridView2.Rows(e.RowIndex).ErrorText = "The value you entered is not valid"
    e.Cancel = True
    End If
    End if
    Private Sub DataGridView2_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellEndEdit

    'For Clearing The Error Message

    DataGridView2.Rows(e.RowIndex).ErrorText = String.Empty

    End Sub
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!