Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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")

Posted

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?

Howzit??
  • *Experts*
Posted

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.

Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...