Databinding to a maskedit control (VB)

timed

Newcomer
Joined
Jan 9, 2003
Messages
8
Location
Sioux Falls, South Dakota
Databinding to a maskedit control

I am having trouble tring to databind information from a dataset that is created and enter it in a maskedit box. When I bind the information to the textboxes evreything is fine it is when i get to the maskedit boxes is where I get the error, any sugestions. Thanks in Advance. I am a beginer to .net

The error that I am reciving is a
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

Additional information: Cannot bind to property or column Phone2 on DataSource.

Here is the code

'Lets bind the data from the DataSet
txtId.DataBindings.Add("Text", dsClients.Tables(0), "iClientID" & "")
txtAddress.DataBindings.Add("Text", dsClients.Tables(0), "cAddress")
txtMiddle.DataBindings.Add("Text", dsClients.Tables(0), "cMiddleName")
txtCity.DataBindings.Add("Text", dsClients.Tables(0), "cCity")
txtState.DataBindings.Add("Text", dsClients.Tables(0), "cState")
txtZip.DataBindings.Add("Text", dsClients.Tables(0), "cZip")
mskPhone.DataBindings.Add("MaskText", dsClients.Tables(0), "cPhone")
mskPhone2.DataBindings.Add("Text", dsClients.Tables(0), "Phone2")
mskSSN.DataBindings.Add("Text", dsClients.Tables(0), "cSSN")
txtNotes.DataBindings.Add("Text", dsClients.Tables(0), "cNotes")
 
Your error is pointing to the mskPhone2's databinding, but I see a problem with your mskPhone' databinding statement.
You are trying to bind to a 'MaskText' property, and I think you meant to bind to the 'Mask' property?
 
I feel I must point out that you shouldn't be using the MaskEditBox
from VB6 in VB.NET; I think the most popular way of doing text-box
validation is to use the 'Validating' event, along with the ErrorProvider
component. Here is a tutorial on that.
 
Thank you, I will take a look into this. I know it is not good to use a maskedit control, but I was in a crunch for time. I am going to take a look at this and start using text validation.
 
Back
Top