Expanding Validation Focus

HeavenCore

Well-known member
Joined
Apr 10, 2007
Messages
77
Location
Bolton, England
Programming Experience
1-3
Yo, got a databound form, which works ok, if i try entering a letter into a numeric field the textbox will not loose focus and locks out the rest of the form until i enter a numeric value etc. Is there a way of catching the validation error, for example "Please Enter A numeric Value" using a simple databinding property or will this have to be done programmatically?

any help would be cool :D

Regards

J

UPDATE: This problem was occuring on a drop down list bound to an Int Database attribute, the comboboxes are bound as follows:
Display Member: bound to a varchar(50)
Display Value: bound to an INT (an INT fk ID basically)
Selected Value: The forms current value

This does not work; however if i change Display member to the int then it does, so i'm guessing the databinding validation thing is looking at database, requesting an int, and the Combobox is trying to send a string? anybody got any ideas?
 
Last edited:
It sounds messed up..

The combo should bind to a list of 2 columns:

One is a string to be displayed.
Other is an associated data of whatever type is needed to be stored in the data table


e.g.

tblPerson has an INTEGER code for the state in which they live.

The combo MUST have a separate underlying list of:
DispMemb, ValueMemb
"Florida", 1
"Texas", 2
...

combo.DataSource = dataset.StatesLookupTable
combo.DisplayMember = "DispMemb"
combo.ValueMember = "ValueMemb"
combo.SelectedValue is bound to dataset.tblPerson.StateID



Please be accurate when you post.. you said:

UPDATE: This problem was occuring on a drop down list bound to an Int Database attribute, the comboboxes are bound as follows:
Display Member: bound to a varchar(50)
Display Value: bound to an INT (an INT fk ID basically)
Selected Value: The forms current value

Display Member --> I know what this is
Display Value --> There is no such thing?? Did you mean Value Member?
Selected Value --> Forms dont have current values - forms are GUI elements, not data elements. You cannot bind to form.CurrentValue because form has no such property..
 
Hello again cjard, this is actually another version of the same jobs form you helped me with yesterday. The thing we came up with was not quite what we needed, this new way i have appraoched it has the jobs datascource as a straight bind, and i am populating the comboboxes with another BindingScource called TblContractBindingSource. although one job can only have one contract at any one time, it could change and so the user wants a list where they can just change this whilst navigating through the recordset.

But yea, this is what i have:

Untitled-3.jpg


ContractName and ContractID are both in same database table, ID is an int and Name is a varchar(50), if i change display member to ContractID it works perfectly, by that i mean, when navigating through the records the combo boxes contain all potential contract id's with the current one selected. and if another is chosen it saves fine in the jobs table, but as soon as i throw ContractName in there so we can tell what the actual numbers mean things go wrong.

Any help you can shed on this would be great.

Regards

J.

PS: few extra details, The combo box is bound to jobs data set, and the data items (contracts) have their own dataset with Contracts table in only (Contracts table is basically a lookuptable with contract ID, Name and description)
 
Last edited:
Set the DropDownStyle to DropDownList, and also ensure that you have removed the binding from .Text

You should only have .SelectedValue bound to tblJobs..
 
Back
Top