setting the combo box value in windows form

V

Vinki

Hello Evryone,

I am an ASP.net developer. I have this combo box in VB.net (Windows form).I
populated the combo box at the form load event. I have a datagrid on my form,
when the user clicks on a datagrid row, I need to programmaticaly set the
value of the combobox based
on whatever the value is on the datagrid. Everytime I set the value, it get
overwritten by form load event and fill up the combo box again. IN asp.net, I
can avoid it by Ispostback, how can I avaoid it here in windows application.
Any help will be greatly appreciated.
 
F

Family Tree Mike

Vinki said:
Hello Evryone,

I am an ASP.net developer. I have this combo box in VB.net (Windows
form).I
populated the combo box at the form load event. I have a datagrid on my
form,
when the user clicks on a datagrid row, I need to programmaticaly set the
value of the combobox based
on whatever the value is on the datagrid. Everytime I set the value, it
get
overwritten by form load event and fill up the combo box again. IN
asp.net, I
can avoid it by Ispostback, how can I avaoid it here in windows
application.
Any help will be greatly appreciated.


The form load is called multiple times? That isn't right.

You should have code similar to this:


Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

' create a handler for the cell click event
AddHandler DataGridView1.CellClick, AddressOf Clicky
End Sub

' in the handler, set the combo to something different.
Private Sub Clicky(sender As Object, e As DataGridViewCellEventArgs)
ComboBox1.SelectedIndex = 2
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top