473,385 Members | 1,676 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.

Bug in CombBox bound to DataRelation

Hi,

I think there's a bug in the ComoBox when binding to a DataRelation.
The problem is that SelectedValueChanged event is not always being
called.

Here is some code to reproduce the problem. Add 2 comboboxes, 2 labels
and a timer to a form. Then add the code at the end of this message.
You will see that, when you select a new item in the child combobox,
the SelectedValueChanged event gets fired, but when you change the
parent combo it does not even though the child combo's selected item
does change.

Maybe I'm not using these controls in the 'right' way...BUT it shows
that, internally, the SelectedValue property _can_ be changed without
the SelectedValueChanged event firing (that's the purpose of the timer
- to prove the value does get updated).

Not a flame, just a polite request to MS to fix =o)

Thanks,

Paul

P.S just updated to Framework 1.1 SP1 today, problem still exists. I'm
guessing fixing this might also cause people problems who have already
coded round it...all of a sudden their events will be firing twice.
Me, I'd prefer to see it working properly and go through removing my
workarounds, just my opinion.

-----------------CODE SNIPPET---------------

int _iCount = 0;

private void Form1_Load(object sender, System.EventArgs e)
{

DataSet dsTemp = new DataSet();
DataTable dtParent = new DataTable("Parent");
DataTable dtChild = new DataTable("Child");

dtParent.Columns.Add("id", typeof(int));
dtParent.Columns.Add("sName", typeof(string));

dtChild.Columns.Add("id", typeof(int));
dtChild.Columns.Add("parentid", typeof(int));
dtChild.Columns.Add("sName", typeof(string));

dtParent.Rows.Add(new object[]{1, "Fruit"});
dtParent.Rows.Add(new object[]{2, "Veg"});

dtChild.Rows.Add(new object[] {1, 1, "Apple"});
dtChild.Rows.Add(new object[] {2, 1, "Pear"});
dtChild.Rows.Add(new object[] {3, 1, "Peach"});
dtChild.Rows.Add(new object[] {4, 2, "Carrot"});
dtChild.Rows.Add(new object[] {5, 2, "Parsnip"});
dtChild.Rows.Add(new object[] {6, 2, "Peas"});

dsTemp.Tables.Add(dtParent);
dsTemp.Tables.Add(dtChild);

DataRelation dRel = dsTemp.Relations.Add("Parent_To_Child",
dtParent.Columns["id"], dtChild.Columns["parentid"], true);

comboBox1.ValueMember = "Parent.id";
comboBox1.DisplayMember = "Parent.sName";

comboBox2.ValueMember = "Parent.Parent_To_Child.id";
comboBox2.DisplayMember = "Parent.Parent_To_Child.sName";

comboBox1.DataSource =
comboBox2.DataSource =
dsTemp;

}

private void comboBox2_SelectedValueChanged(object sender,
System.EventArgs e)
{
_iCount++;
label1.Text = "Events : " + _iCount;
}

private void timer1_Tick(object sender, System.EventArgs e)
{
label2.Text = "comboBox2.SelectValue = " +
((comboBox2.SelectedValue == null) ? "<Null>" :
Convert.ToString(comboBox2.SelectedValue));
}
}
Nov 16 '05 #1
0 1199

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

Similar topics

3
by: serge calderara | last post by:
Dear all, I have a dataset which contains 2 DataTable The idea is to bind a text box control with one table field and then diaplaye the associated content of the second table based on the first...
1
by: yaser | last post by:
Hello: I need save my update but i can't :confused: :confused: :confused: look my code : Imports System.Data Imports System.Data.OleDb Public Class Form1
0
by: Stefan | last post by:
I need help with the following problem. I created a datarelation DataRelation oRelation = new DataRelation("plz_relation",odsAdressenDS.v_plz.plz_idColumn,...
0
by: Fox | last post by:
Is it possible to get back the DataRelation contect from a dataSet? { DataRelation myDataRelation; DataColumn parentColumn; DataColumn childColumn; parentColumn = myDataSet.Tables.Columns;...
1
by: Johann Blake | last post by:
I have a form with a single textbox control which is bound to a DataRelation in a typed dataset. The textbox displays the name of the product depending on the language selected from a combobox....
2
by: Rich | last post by:
Hello, Following an example at http://www.vb-tips.com/dbpages.aspx?IA=DG (by Cor Lightert and Ken Tucker) on binding a dataRelation to a Datagridview for sqlClient, I was able to view rows...
3
by: Bill | last post by:
I have what I think should be a simple question regarding a bound combo box. My first table is Dealers: DealerID - primary key DealerName BillToLocation My second table is Locations:...
1
by: =?Utf-8?B?QWRl?= | last post by:
Hi, I have three datagridview controls bound to three tables in a dataset. Two relations exist to join the three tables. Ie Master to Child1 and then Child 1 to Child 2. The Master and Child 1...
2
by: Tony Johansson | last post by:
Hello! I can't understand what is this table DataRelation used for. I mean as long as you have this DataTable I can't see any point in using this DataRelation. //Tony
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.