PC Review


Reply
Thread Tools Rate Thread

Databinding , Prevent data updated to datasource.

 
 
Michael Andersson
Guest
Posts: n/a
 
      2nd Jan 2007
Hi,
i've got a form with a MaskedTextBox and some other control, which i
used to make the MaskTextBox loose focus.
The MaskedTextBox is databound to a property named "Text" on a Custom
Class, which is a business object. This is the code for the class:
________________________________________________________________
Public Class Class1
Private mText As String = "dlsf"

Public Property Text() As String
Get
Return mText
End Get
Set(ByVal value As String)
mText = value
RaiseEvent TextChanged(Me, System.EventArgs.Empty)
End Set
End Property

Public Event TextChanged As System.EventHandler
End Class
_______________________________________________________________

My MaskedEditBox is initialized and databinding is setup with the
following code in the contructor of the form
_______________________________________________________________
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.
mClass1 = New Class1()
MaskedTextBox1.Mask = "0000-00-00"
MaskedTextBox1.ValidatingType = GetType(Date)
MaskedTextBox1.DataBindings.Add("Text", mClass1, "Text", True,
DataSourceUpdateMode.OnValidation)
End Sub
_______________________________________________________________

My problem is that i can't prevent incomplete values, that the user
enters into the MaskedTextBox1, from being forwarded into my business
object (the Set property of Text). I've tried experimenting with the
MaskedTextBox's Validated,Validating, and TypeValidationCompleted
events but with no success.

Is there some way to prevent the control from updating the datasource
when i know the value is incomplete/incorrect?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding 2 comboboxes to the same Datasource ECathell Microsoft VB .NET 4 17th May 2006 07:03 AM
DataBinding no longer updates underlying datasource when a form is closed? Alex Shoemack Microsoft Dot NET Compact Framework 1 4th Nov 2005 07:58 PM
ADO, SQL, C#, ListBox : DataSource, DisplayMember & DataBinding =?Utf-8?B?ZG9jY3B1?= Microsoft ADO .NET 1 16th Jun 2004 08:10 AM
Help -- datasource property vs databinding?? amy Microsoft ADO .NET 1 1st Aug 2003 03:38 AM
DataSource ChildRelation DataBinding Lance Kowalski Microsoft Dot NET Compact Framework 0 24th Jul 2003 09:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:07 PM.