How do I DataBind to a control when Textbox.visible=false

R

Rob Dob

Hi,

I'm not sure if I going about this the correct way.

I have some databound TextBox's displayed on a winform that are bound to my
BindingSource. When I make modifications to any of these textboxes and
then try to save these changes everything works fine. However I have a
requirement to programmically change the values of some of the other fields
which are part of this same BindingSource. My solution was to create some
additional TextBoxes and then change the property of those textboxes from
visible=true to visible=false, and then programmically change the Text
values of these controls from within my code. The problem is that none of
these changes are being updated for the controls where I have set Visible
=false.

How do I programmically change the values of some of the fields attached to
my BindingSource for which I don't wish to display on my winform, But I
still need the BindingSource to recognize these as changes and still treat
them the same as changes made manually to the other visible=true textboxes.

Thanks,
 
E

Eric Smith

I don't know if I understand your situation completely, but it seems like
you should be able to just change the fields directly on the underlying
object instead of trying to go through a TextBox.

I don't know if you're binding to some regular object or some other data
source, but when I had a class where changing one property also affected
other properties, I implemented INotifyPropertyChanged and fired the event
for all the properties that changed.

--Eric
 
R

Rob Dob

Hi



Thank you for the reply...

">fields directly on the underlying object instead of trying to go through a
TextBox."

How do I go about doing this. within the BindingSource, the Dataset,
where?
 
R

Ranko

Rob said:
Hi,

I'm not sure if I going about this the correct way.

I have some databound TextBox's displayed on a winform that are bound to my
BindingSource. When I make modifications to any of these textboxes and
then try to save these changes everything works fine. However I have a
requirement to programmically change the values of some of the other fields
which are part of this same BindingSource. My solution was to create some
additional TextBoxes and then change the property of those textboxes from
visible=true to visible=false, and then programmically change the Text
values of these controls from within my code. The problem is that none of
these changes are being updated for the controls where I have set Visible
=false.

How do I programmically change the values of some of the fields attached to
my BindingSource for which I don't wish to display on my winform, But I
still need the BindingSource to recognize these as changes and still treat
them the same as changes made manually to the other visible=true textboxes.

Thanks,
If I understand correctly your problem, you can try this(for example):
for untyped dataset:

Dim rowindex As Integer
rowindex = customersBindingSource.Position

customersDataset.Tables("Customers").Rows(rowindex)("LastName") = "Smith"

or for typed dataset:
customersDataset.Customers(rowindex).LastName = "Smith"

or
customersDataset.Customers(rowindex).LastName = LastNameTextBox.Text
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top