Formatting Text Boxes with Data Relations

M

msmcg

I need to format the data in some textboxes using the
Binding method with custom Currency and ShortDate format
and parse handlers.

Here is the code that I am using. I call it on the form
load event:


Private Sub setTextBoxDataBindings()

'set default value for Boolean data fields

Me.objdsContractMgmt.tblContract.PortfolioPlusColumn.Defau
ltValue = False

Dim b1 As New Binding("text",
objdsContractMgmt, "tblContract.ContractEffectiveDate")
AddHandler b1.Format, AddressOf FormatShortDate
AddHandler b1.Parse, AddressOf ParseShortDate
Dim b2 As New Binding("text",
objdsContractMgmt, "tblContract.ContractExpirationDate")
AddHandler b2.Format, AddressOf FormatShortDate
AddHandler b2.Parse, AddressOf ParseShortDate
Dim b3 As New Binding("text",
objdsContractMgmt, "tblContract.LOCDate")
AddHandler b3.Format, AddressOf FormatShortDate
AddHandler b3.Parse, AddressOf ParseShortDate
Dim b4 As New Binding("text",
objdsContractMgmt, "tblContract.PriceProtectionDate")
AddHandler b4.Format, AddressOf FormatShortDate
AddHandler b4.Parse, AddressOf ParseShortDate
Dim b5 As New Binding("text",
objdsContractMgmt, "tblContract.DateAssigned")
AddHandler b5.Format, AddressOf FormatShortDate
AddHandler b5.Parse, AddressOf ParseShortDate
Dim b6 As New Binding("text",
objdsContractMgmt, "tblContract.rlnContractItems.OriginalS
pend")
AddHandler b6.Format, AddressOf FormatCurrency
AddHandler b6.Parse, AddressOf ParseCurrency


Me.editEffectiveDate.DataBindings.Add(b1)
Me.editExpirationDate.DataBindings.Add(b2)
Me.editLOCSignedDate.DataBindings.Add(b3)
Me.EditProtectedDate.DataBindings.Add(b4)
Me.editAssignedDate.DataBindings.Add(b5)

Me.editItemOriginalSpend.DataBindings.Add(b6)

End Sub

I have successfully done this for the top table in my
dataset. My dataset has 4 levels of relations. (1-M-M-M)

The code above shows the bindings that I create for each
text box or label needing special formatting. The first 5
work great. But when I introduced the 6th one, I get this
error when loading the dataset:

"Failed to enable constraints. One or more rows contain
values violating non-null, unique or foreign-key
constraints"

This field is in the child table to the top parent table.
I cannot find any examples of creating bindings like this
using relations and child tables. If I bind the text box
directly (in the UI Designer properties window) with no
special formatting, everything works fine, although the
data looks bad.

What am I doing wrong? Any help is always appreciated!

Thanks is advance...
 
H

Herfried K. Wagner [MVP]

Hello,

msmcg said:
I need to format the data in some textboxes using the
Binding method with custom Currency and ShortDate
format and parse handlers.

You will more likely get an answer to your question if you post the question
in this group:

news://news.microsoft.com/microsoft.public.dotnet.framework.windowsforms.databinding
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top