Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi to all

I have a datagridview with 1 combobox and 2 textbox

i want when the user update the combobox the program fill the first textbox.

I have the code for validation but i dont know how to take the value of the combobox

VB
Private Sub dataGridView1_CellValidating(ByVal sender As Object, ByVal e As DataGridViewCellValidatingEventArgs) Handles Movement_roller_DDataGridView.CellValidating

    Dim headerText As String = _
        Movement_roller_DDataGridView.Columns(e.ColumnIndex).HeaderText

    ' Abort validation if cell is not in the CompanyName column.
    If Not headerText.Equals("Κωδικος Roller") Then Return

    ' Confirm that the cell is not empty.
    If (String.IsNullOrEmpty(e.FormattedValue.ToString())) Then
        Movement_roller_DDataGridView.Rows(e.RowIndex).ErrorText = "Ο Κωδικώς Roller δεν μπορεί να είναι κενός"
        e.Cancel = True
    End If
End Sub
Posted

 
Share this answer
 
Go through the folllowing link will help you

Getting-Selected-Value-Combo-Box[^]
 
Share this answer
 
Comments
Vagelisr 28-Apr-11 9:36am    
Hi and thanks for the post.... but in this examples you have send to me they did not help me at all
I want in my combobox to show the description and to get the id .
If i want to take back what combobox show in my code i will have to add an else in the If (String.IsNullOrEmpty(e.FormattedValue.ToString())) Then and show the e.FormattedValue.ToString
i want in my combobox to show the description and take back the id.
and

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900