Currency manager does NOT change content of run-time bound control

C

Christian

Hi,

I have one databound-control for which I set the DataBinding properties at
design-time as follows :
the Text-property of a label-control 'lblProductname' is bound to the
field
"Productname" in a DataSet named DsProducts1.Products

and I have another databound-control for which I set the DataBinding
properties at run-time :
lblUnitsInStock.DataBindings.Add("Text", DsProducts1.Products,
"UnitsInStock")

Then using a currency manager :
Dim m_cm As CurrencyManager
m_cm = Me.BindingContext(DsProducts1, "Products")

Now when I click on a button "Next"
Private Sub btnNext_Click(.....) Handles btnNext.Click
m_cm.Position += 1
End Sub

.... does the data in the design-time control change but the data in the
run-time bound control does NOT change ???

how come ?
thnx

Chris
 
M

Miha Markic [MVP C#]

Hi Christian,

You are using wrong currencymanager.
It should be (same as when binding):
m_cm = Me.BindingContext(DsProducts1.Products)
 
C

Christian

Hi Miha,

thanks for the tip and indeed the runtime bound control now changes when
clicking the next button ... but now the design-time bound controls don't
change anymore.

So it's either the runtime- or design-time bound controls that change ???
How to have both changed when using the currency manager ?

thnx

Christian

Miha Markic said:
Hi Christian,

You are using wrong currencymanager.
It should be (same as when binding):
m_cm = Me.BindingContext(DsProducts1.Products)

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Christian said:
Hi,

I have one databound-control for which I set the DataBinding properties at
design-time as follows :
the Text-property of a label-control 'lblProductname' is bound to the
field
"Productname" in a DataSet named DsProducts1.Products

and I have another databound-control for which I set the DataBinding
properties at run-time :
lblUnitsInStock.DataBindings.Add("Text", DsProducts1.Products,
"UnitsInStock")

Then using a currency manager :
Dim m_cm As CurrencyManager
m_cm = Me.BindingContext(DsProducts1, "Products")

Now when I click on a button "Next"
Private Sub btnNext_Click(.....) Handles btnNext.Click
m_cm.Position += 1
End Sub

... does the data in the design-time control change but the data in the
run-time bound control does NOT change ???

how come ?
thnx

Chris
 
M

Miha Markic [MVP C#]

Hi Christian,

Check out how designer binds controls (see Windows Forms Designer generated
code region) and use similar approach for binding runtime controls.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Christian said:
Hi Miha,

thanks for the tip and indeed the runtime bound control now changes when
clicking the next button ... but now the design-time bound controls don't
change anymore.

So it's either the runtime- or design-time bound controls that change ???
How to have both changed when using the currency manager ?

thnx

Christian

Miha Markic said:
Hi Christian,

You are using wrong currencymanager.
It should be (same as when binding):
m_cm = Me.BindingContext(DsProducts1.Products)

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Christian said:
Hi,

I have one databound-control for which I set the DataBinding
properties
 

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