Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BeforeUpdate event

Status
Not open for further replies.

HJBPS

Programmer
Apr 25, 2008
8
US
Hii, I am new to .net, I was doing a VB6 before. I added a combobox to my form and it is set as dropdown only. When the selection is changed, i want to know what the old value was before selection changed. I do not see a beforeupdate event for the combo box.
Is there a beforeupdate event and I am not seeing or is it done away with?
If yes, how do i get old value? I only see new value using textchanged or selectionchanged events? Pls help?
 
You could always place code in the GotFocus event.

the code below will give the the current selection:'
Code:
cboName.SelectedItem.ToString

This value can be saved to a variable and you can use that to compare the newly selected item in the SelectedIndexChanged event (or anywhere else).

eg. If strTextOld = cboName.SelectedItem.ToString then ...

Hope this helps.
 
Blue jay, thanks for that answer but here's my problem.
The got focus event is good once they come in from another field, but my code needs to know the change even when they have changed it while in the field. I am populating a grid based on choice changes.
Changing the combo box even while in the field needs to change data in the grid. The got focus will not work in that case.
 
You could also add code to the SelectedItemIndex changed (or any of the similiar events). Take a look at the vb help for indo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top