473,320 Members | 1,916 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,320 software developers and data experts.

Updating the form's fields

Hi All!

I am with a situation where I am not getting the right updating to the
form's fields. The situation is the following one:

I have one combobox and one textbox. I am using the CurrentChanged event of
the BindingSource of the combobox to update the textbox. When selecting an
item in the combobox or when selecting a row in the grid, it is updating the
textbox correctly. The problem is when I apply a filter in the grid, and then
the grid has no rows. I already made the following attempts:

- When there is no row in the grid, the event is not called, and textbox
mantains the previous content;
- If I call the CurrentChanged event directly when there is no rows in the
grid, in this case I clean up the textbox, but when I apply a filter again in
the grid and the position of the combobox does not modify (that is, it is in
the same register), the CurrentChanged is not called, and edit is blank
(because I cleaned before);
- I already tried to use “combo.SelectedIndex = -1” but also did not worked.

Does someone has any idea of how can I solve this situation?

Thank you for any suggestion!
Vanessa
Mar 11 '08 #1
2 3287
Hi Vanessa,

I suspect you get some invalid data breaking the databinding. Try handling
the DataError event of the BindingSource.

It is a bit unclear what you have databound and not, and in fact what
controls you have. What is the relationship between the (data)grid and the
combobox? Are you databinding a ComboBox to one BindingSource and a DataGrid
to another, while the TextBox remains unbound and is updated manually when a
change occurs in either the ComboBox or the DataGrid?

Other things to try. Bind the TextBox to the same BindingSource as the
ComboBox rather than updating it in the CurrentChanged event (although this
won't work if you use the same TextBox to display values from another
BindingSource as well). Try handling the ListChanged event, which should
fire if the underlying datasource changes. If the list is changed, get the
BindingSource.Current value and update the TextBox accordingly.

--
Happy Coding!
Morten Wennevik [C# MVP]
"Vanessa" wrote:
Hi All!

I am with a situation where I am not getting the right updating to the
form's fields. The situation is the following one:

I have one combobox and one textbox. I am using the CurrentChanged event of
the BindingSource of the combobox to update the textbox. When selecting an
item in the combobox or when selecting a row in the grid, it is updating the
textbox correctly. The problem is when I apply a filter in the grid, and then
the grid has no rows. I already made the following attempts:

- When there is no row in the grid, the event is not called, and textbox
mantains the previous content;
- If I call the CurrentChanged event directly when there is no rows in the
grid, in this case I clean up the textbox, but when I apply a filter again in
the grid and the position of the combobox does not modify (that is, it is in
the same register), the CurrentChanged is not called, and edit is blank
(because I cleaned before);
- I already tried to use “combo.SelectedIndex = -1” but also did not worked.

Does someone has any idea of how can I solve this situation?

Thank you for any suggestion!
Vanessa
Mar 12 '08 #2
Hi Morten!

Let me explain better what I want to do.

My database has the following tables:

Table A - the main table that is shown in the form. It has a field that is a
key into Table B;
Table B - it is related to Table A and it is a combobox in the form. It has
a field that is a key into Table C;
Table C - it is related to Table B and it has a description field to show in
a textbox.

So, my question is, how can I make the binding to the textbox that is on
Table C? What I want is to show the description field from Table C, whose key
is on the Table B (combobox).

Thank you,
Vanessa

"Morten Wennevik [C# MVP]" wrote:
Hi Vanessa,

I suspect you get some invalid data breaking the databinding. Try handling
the DataError event of the BindingSource.

It is a bit unclear what you have databound and not, and in fact what
controls you have. What is the relationship between the (data)grid and the
combobox? Are you databinding a ComboBox to one BindingSource and a DataGrid
to another, while the TextBox remains unbound and is updated manually when a
change occurs in either the ComboBox or the DataGrid?

Other things to try. Bind the TextBox to the same BindingSource as the
ComboBox rather than updating it in the CurrentChanged event (although this
won't work if you use the same TextBox to display values from another
BindingSource as well). Try handling the ListChanged event, which should
fire if the underlying datasource changes. If the list is changed, get the
BindingSource.Current value and update the TextBox accordingly.

--
Happy Coding!
Morten Wennevik [C# MVP]
"Vanessa" wrote:
Hi All!

I am with a situation where I am not getting the right updating to the
form's fields. The situation is the following one:

I have one combobox and one textbox. I am using the CurrentChanged event of
the BindingSource of the combobox to update the textbox. When selecting an
item in the combobox or when selecting a row in the grid, it is updating the
textbox correctly. The problem is when I apply a filter in the grid, and then
the grid has no rows. I already made the following attempts:

- When there is no row in the grid, the event is not called, and textbox
mantains the previous content;
- If I call the CurrentChanged event directly when there is no rows in the
grid, in this case I clean up the textbox, but when I apply a filter again in
the grid and the position of the combobox does not modify (that is, it is in
the same register), the CurrentChanged is not called, and edit is blank
(because I cleaned before);
- I already tried to use “combo.SelectedIndex = -1” but also did not worked.

Does someone has any idea of how can I solve this situation?

Thank you for any suggestion!
Vanessa
Mar 12 '08 #3

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

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
5
by: Richard Stanton | last post by:
Hello all My database has a main form linked to table1. It has several subforms on the main form, all linked to table2. Table1 and Table2 are linked by primary/foreign key, no duplicates...
3
by: MLH | last post by:
I have a form, bound to a query. Its RecordSource property is a query named frmEnterLienAmounts. The form has a few bound controls and some unbound controls. The unbound controls are calculated...
3
by: Tc | last post by:
Hi, I was curious, I am thinking of writing an application that loads a dataset from a database that resides on a server. The question I have is this, if multiple copies of the app will be...
1
by: Spock | last post by:
Hi. I have a form with a listbox and a few label fields all bound to a dataset. When i navigate the listbox the labels change accordingly. so far everything works good. I made a button to...
9
by: Kevin Blount | last post by:
Here's the code I tried, and found it failed... <form runat="server" method="post" name="CreditCardForm" id="CreditCardForm"> <% foreach (object item in Request.Form) { if...
1
by: EyeHawk | last post by:
OK, hopefully somebody can help me out again. My next problem is updating 3 form fields (type list/menu option) that correspond to a date, one for month, one for day and one for year when the user...
4
by: AlexNunley | last post by:
I've adopted a moderately sized (65k records) active use database (Access 2000, Windows XP). One of the most commonly used forms is whats called the RMA generation field, used to add claim...
0
by: Mike | last post by:
So here's the situation (.NET 2.0 btw): I have a form, and on this form is a textbox among many other databound controls. The textbox is bound to a field in a data table via the Text property. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.