I have a textbox that is databound to a datacolumn in a table that is created with a tableadapter. I have noticed that the designer automatically sets the column length according to the column length in the database.
When more data is entered in the textbox then is allowed, a first chance exception is generated and it is impossible to leave the textbox. Can I somehowe catch the event that does this length controll and inform my user that to much text is entered?Hi, You can definately bind the MaxLength property of a textbox with ds.Tables[0].Columns[0].MaxLength This will not allow users to enter more then the size of column.-- RegardsJignesh Desai <mikael sandberg@.discussions.microsoft.com> wrote in message news:75a7ef18-e360-4704-987c-c43bc8a869c6@.discussions.microsoft.com...I use VB 2005 and ADO.2.0I have a textbox that is databound to a datacolumn in a table that is created with a tableadapter. I have noticed that the designer automatically sets the column length according to the column length in the database. When more data is entered in the textbox then is allowed, a first chance exception is generated and it is impossible to leave the textbox. Can I somehowe catch the event that does this length controll and inform my user that to much text is entered?
Thanks for the quick answer. I had your solution in mind but there are more to it.
I have the datarow encapsulated in a class as part of a business layer. The class exposes properties like this:
Property FName() As String
Get
Return drCustomer.FName
End Get
Set(ByVal Value As String)
drCustomer.FName = Value
End Set
End Property
I have done like this to encapsulate the data in a nice manner.
I then databind the property to a textbox. It seems that the textbox fires an event that encounters an error that to much data is present. I don't want to expose the max length, I want to catch the error and notify the user. Can this be done
No comments:
Post a Comment