473,385 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Force update of Databinding

I've got a combobox where the SelectedValue property is bound to a class
property by a code like this:

MyComboBox.DataBindings.Add("SelectedValue", MyClass , "MyID");

My problem is that the MyClass.MyID property gets updated when the focus
leaves the combobox - not when you actually select a new item from the drdop
down list.

I would have expected this code to solve the problem, but it didn't:
MyComboBox.DataBindings.DefaultDataSourceUpdateMod e =
DataSourceUpdateMode.OnPropertyChanged;

I would do a work around and do a method in my class called UpdateMyID(long
MyIDValue) and call it from the MyComboBox_SelectedItemChanged event (which
is fired correctly), but the drop down list in the combo is data bound with
a ValueMember which is the ID in long format and a DisplayMember which is
the Value in string format, and I can't figure out how to get the
ValueMember from the SelectedItem and use it in calling my method. There is
apparently no SelectedItem.ValueMember property, and as far as I can see in
the intellisense no way of getting the ValueMember property

The best would be if I could programmatically for the databinding to update,
but there is no

MyComboBox.DataBindings.Refresh

method either.

Any suggestions as to how I can solve it?

Cheers,

Johnny J.


May 8 '07 #1
1 6865
I found another way to skin the cat, so please forget this post.

Cheers,
Johnny J.

"Johnny Jörgensen" <jo**@altcom.sewrote in message
news:Om**************@TK2MSFTNGP06.phx.gbl...
I've got a combobox where the SelectedValue property is bound to a class
property by a code like this:

MyComboBox.DataBindings.Add("SelectedValue", MyClass , "MyID");

My problem is that the MyClass.MyID property gets updated when the focus
leaves the combobox - not when you actually select a new item from the
drdop down list.

I would have expected this code to solve the problem, but it didn't:
MyComboBox.DataBindings.DefaultDataSourceUpdateMod e =
DataSourceUpdateMode.OnPropertyChanged;

I would do a work around and do a method in my class called
UpdateMyID(long MyIDValue) and call it from the
MyComboBox_SelectedItemChanged event (which is fired correctly), but the
drop down list in the combo is data bound with a ValueMember which is the
ID in long format and a DisplayMember which is the Value in string format,
and I can't figure out how to get the ValueMember from the SelectedItem
and use it in calling my method. There is apparently no
SelectedItem.ValueMember property, and as far as I can see in the
intellisense no way of getting the ValueMember property

The best would be if I could programmatically for the databinding to
update, but there is no

MyComboBox.DataBindings.Refresh

method either.

Any suggestions as to how I can solve it?

Cheers,

Johnny J.


May 8 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dmitry Karneyev | last post by:
Hi! I've got a DataSet with tables corresponding to the database ones. And I've got a table for my calculations and databinding in app. To fill "my" table I use myTable.Rows.Add(...) and then edit...
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
0
by: Patrick B | last post by:
I'm wondering about the mechanics of databinding. Say that a textbox is bound to a property of a business object. The business object is a "Person". The control is a textbox called...
2
by: louise raisbeck | last post by:
Hi, There seem to be several ways to update rows in sql. What is the best practice? I have written a medium sized update statement into a stored procedure, taking values from the web text...
5
by: Stephen Plotnick | last post by:
I'm very new to VB.NET 2003 Here is what I have accomplished: MainSelectForm - Selects an item In a public class I pass a DataViewRow to ItemInformation1 Form ItemInformation2 Form
6
by: bryanbabula | last post by:
I have a question about overriding i was wondering if anyone could help me with, or even suggesting a better/different way. I have no idea if this can even be done or not. I was wondering if there...
5
by: Randy | last post by:
I have button that deletes items from a SQL datatable. The items are displayed for the user in listbox, which is bound to the dataset. The code works just fine insofar as it deletes the correct...
3
by: Brad Baker | last post by:
I have a formview with a datasource that contains a select and update command. The select statement works fine but the update command doesn't seem to be working. After some troubleshooting I have...
0
by: cmrchs | last post by:
Hi, I'm trying out Databinding to a Data Acces Layer using a GridView and ObjectDataSource-control The Update works fine but the Delete-method doesn't ??? <asp:GridView ID="GridView1"...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.