binding to a usercontrol

  • Thread starter Malcolm Busfield via .NET 247
  • Start date
M

Malcolm Busfield via .NET 247

Hi

I am trying to bind a dataview to a number of textboxes, comboboxes and my own control, which contains 2 radio buttons and I am using the currency manager to hold it all together. I bind to the default view of the dataset and i just look at the first row.

I am having problems in that the dataset.haschanges property is set to true when i have not made any changes. I removed the binding of my own control and everything is ok. Does there need to be anything special about the property you bind to?

Code:

In screen close event (I set the position of the currency manager to itself as it seems to help the dataset understand if it has changed):

currencym.Position = currencym.Position
If ds.HasChanges Then 'the dataset has changed
msgbox "Changes have not been saved"

Code to bind the property:

ynQuestion.DataBindings.Add("questionvalue", dv, "question")

Property from control:

Public Property QuestionValue() As Boolean
Get
Return optYes.Checked
End Get
Set(ByVal Value As Boolean)
If Value Then
optYes.Checked = True
Else
optNo.Checked = True
End If
End Set
End Property

Thanks in advance for any help
 
F

Frans Bouma [C# MVP]

Malcolm said:
Hi

I am trying to bind a dataview to a number of textboxes, comboboxes and my
own control, which contains 2 radio buttons and I am using the currency
manager to hold it all together. I bind to the default view of the dataset
and i just look at the first row.

I am having problems in that the dataset.haschanges property is set to true
when i have not made any changes. I removed the binding of my own control
and everything is ok. Does there need to be anything special about the
property you bind to?

Code:

In screen close event (I set the position of the currency manager to itself
as it seems to help the dataset understand if it has changed):

currencym.Position = currencym.Position
If ds.HasChanges Then 'the dataset has changed
msgbox "Changes have not been saved"

Code to bind the property:

ynQuestion.DataBindings.Add("questionvalue", dv, "question")

Property from control:

Public Property QuestionValue() As Boolean
Get
Return optYes.Checked
End Get
Set(ByVal Value As Boolean)
If Value Then
optYes.Checked = True
Else
optNo.Checked = True
End If
End Set
End Property

Thanks in advance for any help
Do you have by any chance an eventhandler defiend on optYes.CheckedChanged?
If so, it gets fired when yuo set the checked value in code as well.

FB
 

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