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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataBinding and SelectedValueChanged

Status
Not open for further replies.

aTekTipsUser

Programmer
Nov 8, 2004
68
US
I have a form that uses databinding. On the form, there is a drop down and the user can select a contact, which populates the address of the contact. The user can change the address if they need to send information to a different address. The issue that I am having is determining (in code) if the user selected the value or if it is due to the records moving. In both cases, the SelectedValueChanged is called. There is no PositionChanging to determine when moving records has started, only PositionChanged which informs me when the Position has changed.

Is there anyway that I can have the dropdown which populates the fields if the user changes the value, but if it is due to position changing, not run the code that populates the fields. Thanks in advance!
 

I usually achieve this by amending the code on the 'move records' button.

Before move:
remove the event handler for the SelectedValueChanged of the combo

After move:
add it back again

Alternatively, set a flag (_moving) to true before moving records and back to false after. Amend you're selectedIndexChanged handler to return with no action if _moving is true.

HTH, post back if you need a demo.

Graeme

"Just beacuse you're paranoid, don't mean they're not after you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top