I have a window application. On one of the form, there is a listbox and a
few combox. The lstSchItem has a dataview as a datasource. The comboxes are
bind to its selected value but through the dataset table. Now when I change
the selection in the lstSchItem the comboxes are staying the same and not
reflecting the changes. I tried changing the binding to the dataview.table
but the comboxes are still not changing to reflect the different selection in
the lstSchItem. I appreciate some suggestions or help on how to correct this
problem.
Thank you, Alpha
cmbServiceItem.DataBindings.Add("SelectedValue",dv SchItems.Table,
"ExtServiceItemID");
cmbCycle1.DataBindings.Add("SelectedValue", dvSchItems.Table,
"ExtCycleID1");
cmbCycle2.DataBindings.Add("SelectedValue", dvSchItems.Table,
"ExtCycleID2");
cmbAndOr.DataBindings.Add("SelectedItem", dvSchItems.Table, "AndOr");
private void ScheduleItems_Load(object sender, System.EventArgs e)
{
try
{
cmbScheudle.DataSource = dsSchItems.Tables["Schedule"];
cmbScheudle.DisplayMember = "ScheduleName";
cmbScheudle.ValueMember = "SchID";
if(cmbScheudle.Items.Count>0)
cmbScheudle.SelectedIndex = 0;
else
btnAdd.Enabled = false;
tblSchItems = dsSchItems.Tables["ScheduleItems"];
dvSchItems.Table = tblSchItems;
if(cmbScheudle.Items.Count>0)
dvSchItems.RowFilter = FilterExp + cmbScheudle.SelectedValue.ToString();
dvSchItems.Sort = SortExp;
// lstSchItem.DataSource = dsSchItems.Tables["ScheduleItems"];
lstSchItem.DataSource = dvSchItems;
lstSchItem.DisplayMember = "SchItemCode";
lstSchItem.ValueMember = "SchItemID";
cmbServiceItem.DataSource = dsSchItems.Tables["ServiceItems"];
cmbServiceItem.DisplayMember = "ServiceName";
cmbServiceItem.ValueMember = "ServiceItemID";
cmbCycle1.DataSource = dsSchItems.Tables["ServiceCycle1"];
cmbCycle1.DisplayMember = "CLU";
cmbCycle1.ValueMember = "CycleID";
//Add a blank entry
DataRow BlankCyc2Item = dsSchItems.Tables["ServiceCycle2"].NewRow();
BlankCyc2Item["CycleID"] = -1;
BlankCyc2Item["CLU"] = "";
dsSchItems.Tables["ServiceCycle2"].Rows.Add(BlankCyc2Item);
dsSchItems.Tables["ServiceCycle2"].AcceptChanges();
cmbCycle2.DataSource = dsSchItems.Tables["ServiceCycle2"];
cmbCycle2.DisplayMember = "CLU";
cmbCycle2.ValueMember = "CycleID";
cmbAndOr.Items.Add("");
cmbAndOr.Items.Add("And");
cmbAndOr.Items.Add("Or");
// lstSchItem.DataBindings.Add("SelectedValue",
dsSchItems.Tables["Schedule"], "SchID");
cmbServiceItem.DataBindings.Add("SelectedValue",ds SchItems.Tables["ScheduleItems"], "ExtServiceItemID");
cmbCycle1.DataBindings.Add("SelectedValue",
dsSchItems.Tables["ScheduleItems"], "ExtCycleID1");
cmbCycle2.DataBindings.Add("SelectedValue",
dsSchItems.Tables["ScheduleItems"], "ExtCycleID2");
cmbAndOr.DataBindings.Add("SelectedItem",
dsSchItems.Tables["ScheduleItems"], "AndOr");
//if no schedule items to the selected scheudle then disable all the
related selection box
if (lstSchItem.Items.Count<=0)
{
// cmbServiceItem.SelectedValue = -1;
cmbServiceItem.Enabled = false;
// cmbCycle1.SelectedValue = -1;
cmbCycle1.Enabled = false;
// cmbCycle2.SelectedValue = -1;
cmbCycle2.Enabled = false;
// cmbAndOr.SelectedValue = -1;
cmbAndOr.Enabled = false;
}
else
{
// lstSchItem.SelectedIndex = 0;
ExtServiceItemID = Convert.ToInt32(cmbServiceItem.SelectedValue);
ExtCycleID1 = Convert.ToInt32(cmbCycle1.SelectedValue);
ExtCycleID2 = Convert.ToInt32(cmbCycle2.SelectedValue);
AndOr = cmbAndOr.SelectedItem.ToString();
}
First = false;
}
catch(Exception ex)
{
MessageBox.Show("Error binding the database to controls,please contact
your support person. : " + ex.ToString()
, "VMS - Control datasource error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} 2 1952
Hi,
"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:18**********************************@microsof t.com... I have a window application. On one of the form, there is a listbox and a few combox. The lstSchItem has a dataview as a datasource. The comboxes are bind to its selected value but through the dataset table. Now when I change the selection in the lstSchItem the comboxes are staying the same and not reflecting the changes. I tried changing the binding to the dataview.table but the comboxes are still not changing to reflect the different selection in the lstSchItem. I appreciate some suggestions or help on how to correct this problem.
If you bind lstSchItem to a DataView then you need to bind
SelectedValue/SelectedItem to the same DataView:
....
lstSchItem.DataSource = dvSchItems;
....
cmbServiceItem.DataBindings.Add("SelectedValue", dvSchItems,
"ExtServiceItemID");
....
HTH,
Greetings
Thank you, Alpha
cmbServiceItem.DataBindings.Add("SelectedValue",dv SchItems.Table, "ExtServiceItemID"); cmbCycle1.DataBindings.Add("SelectedValue", dvSchItems.Table, "ExtCycleID1"); cmbCycle2.DataBindings.Add("SelectedValue", dvSchItems.Table, "ExtCycleID2"); cmbAndOr.DataBindings.Add("SelectedItem", dvSchItems.Table, "AndOr");
private void ScheduleItems_Load(object sender, System.EventArgs e) {
try { cmbScheudle.DataSource = dsSchItems.Tables["Schedule"]; cmbScheudle.DisplayMember = "ScheduleName"; cmbScheudle.ValueMember = "SchID"; if(cmbScheudle.Items.Count>0) cmbScheudle.SelectedIndex = 0; else btnAdd.Enabled = false;
tblSchItems = dsSchItems.Tables["ScheduleItems"]; dvSchItems.Table = tblSchItems; if(cmbScheudle.Items.Count>0) dvSchItems.RowFilter = FilterExp + cmbScheudle.SelectedValue.ToString(); dvSchItems.Sort = SortExp;
// lstSchItem.DataSource = dsSchItems.Tables["ScheduleItems"]; lstSchItem.DataSource = dvSchItems; lstSchItem.DisplayMember = "SchItemCode"; lstSchItem.ValueMember = "SchItemID";
cmbServiceItem.DataSource = dsSchItems.Tables["ServiceItems"]; cmbServiceItem.DisplayMember = "ServiceName"; cmbServiceItem.ValueMember = "ServiceItemID";
cmbCycle1.DataSource = dsSchItems.Tables["ServiceCycle1"]; cmbCycle1.DisplayMember = "CLU"; cmbCycle1.ValueMember = "CycleID";
//Add a blank entry DataRow BlankCyc2Item = dsSchItems.Tables["ServiceCycle2"].NewRow(); BlankCyc2Item["CycleID"] = -1; BlankCyc2Item["CLU"] = ""; dsSchItems.Tables["ServiceCycle2"].Rows.Add(BlankCyc2Item); dsSchItems.Tables["ServiceCycle2"].AcceptChanges(); cmbCycle2.DataSource = dsSchItems.Tables["ServiceCycle2"]; cmbCycle2.DisplayMember = "CLU"; cmbCycle2.ValueMember = "CycleID";
cmbAndOr.Items.Add(""); cmbAndOr.Items.Add("And"); cmbAndOr.Items.Add("Or");
// lstSchItem.DataBindings.Add("SelectedValue", dsSchItems.Tables["Schedule"], "SchID"); cmbServiceItem.DataBindings.Add("SelectedValue",ds SchItems.Tables["ScheduleItems"], "ExtServiceItemID"); cmbCycle1.DataBindings.Add("SelectedValue", dsSchItems.Tables["ScheduleItems"], "ExtCycleID1"); cmbCycle2.DataBindings.Add("SelectedValue", dsSchItems.Tables["ScheduleItems"], "ExtCycleID2"); cmbAndOr.DataBindings.Add("SelectedItem", dsSchItems.Tables["ScheduleItems"], "AndOr"); //if no schedule items to the selected scheudle then disable all the related selection box
if (lstSchItem.Items.Count<=0) { // cmbServiceItem.SelectedValue = -1; cmbServiceItem.Enabled = false; // cmbCycle1.SelectedValue = -1; cmbCycle1.Enabled = false; // cmbCycle2.SelectedValue = -1; cmbCycle2.Enabled = false; // cmbAndOr.SelectedValue = -1; cmbAndOr.Enabled = false; } else { // lstSchItem.SelectedIndex = 0; ExtServiceItemID = Convert.ToInt32(cmbServiceItem.SelectedValue); ExtCycleID1 = Convert.ToInt32(cmbCycle1.SelectedValue); ExtCycleID2 = Convert.ToInt32(cmbCycle2.SelectedValue); AndOr = cmbAndOr.SelectedItem.ToString(); }
First = false; } catch(Exception ex) { MessageBox.Show("Error binding the database to controls,please contact your support person. : " + ex.ToString() , "VMS - Control datasource error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
I binded them to the dvSchItems.Table. I removed the ".Table" and it works
now. Thank you very much.
Alpha
"Bart Mermuys" wrote: Hi,
"Alpha" <Al***@discussions.microsoft.com> wrote in message news:18**********************************@microsof t.com...I have a window application. On one of the form, there is a listbox and a few combox. The lstSchItem has a dataview as a datasource. The comboxes are bind to its selected value but through the dataset table. Now when I change the selection in the lstSchItem the comboxes are staying the same and not reflecting the changes. I tried changing the binding to the dataview.table but the comboxes are still not changing to reflect the different selection in the lstSchItem. I appreciate some suggestions or help on how to correct this problem.
If you bind lstSchItem to a DataView then you need to bind SelectedValue/SelectedItem to the same DataView:
.... lstSchItem.DataSource = dvSchItems; .... cmbServiceItem.DataBindings.Add("SelectedValue", dvSchItems, "ExtServiceItemID"); ....
HTH, Greetings
Thank you, Alpha
cmbServiceItem.DataBindings.Add("SelectedValue",dv SchItems.Table, "ExtServiceItemID"); cmbCycle1.DataBindings.Add("SelectedValue", dvSchItems.Table, "ExtCycleID1"); cmbCycle2.DataBindings.Add("SelectedValue", dvSchItems.Table, "ExtCycleID2"); cmbAndOr.DataBindings.Add("SelectedItem", dvSchItems.Table, "AndOr");
private void ScheduleItems_Load(object sender, System.EventArgs e) {
try { cmbScheudle.DataSource = dsSchItems.Tables["Schedule"]; cmbScheudle.DisplayMember = "ScheduleName"; cmbScheudle.ValueMember = "SchID"; if(cmbScheudle.Items.Count>0) cmbScheudle.SelectedIndex = 0; else btnAdd.Enabled = false;
tblSchItems = dsSchItems.Tables["ScheduleItems"]; dvSchItems.Table = tblSchItems; if(cmbScheudle.Items.Count>0) dvSchItems.RowFilter = FilterExp + cmbScheudle.SelectedValue.ToString(); dvSchItems.Sort = SortExp;
// lstSchItem.DataSource = dsSchItems.Tables["ScheduleItems"]; lstSchItem.DataSource = dvSchItems; lstSchItem.DisplayMember = "SchItemCode"; lstSchItem.ValueMember = "SchItemID";
cmbServiceItem.DataSource = dsSchItems.Tables["ServiceItems"]; cmbServiceItem.DisplayMember = "ServiceName"; cmbServiceItem.ValueMember = "ServiceItemID";
cmbCycle1.DataSource = dsSchItems.Tables["ServiceCycle1"]; cmbCycle1.DisplayMember = "CLU"; cmbCycle1.ValueMember = "CycleID";
//Add a blank entry DataRow BlankCyc2Item = dsSchItems.Tables["ServiceCycle2"].NewRow(); BlankCyc2Item["CycleID"] = -1; BlankCyc2Item["CLU"] = ""; dsSchItems.Tables["ServiceCycle2"].Rows.Add(BlankCyc2Item); dsSchItems.Tables["ServiceCycle2"].AcceptChanges(); cmbCycle2.DataSource = dsSchItems.Tables["ServiceCycle2"]; cmbCycle2.DisplayMember = "CLU"; cmbCycle2.ValueMember = "CycleID";
cmbAndOr.Items.Add(""); cmbAndOr.Items.Add("And"); cmbAndOr.Items.Add("Or");
// lstSchItem.DataBindings.Add("SelectedValue", dsSchItems.Tables["Schedule"], "SchID"); cmbServiceItem.DataBindings.Add("SelectedValue",ds SchItems.Tables["ScheduleItems"], "ExtServiceItemID"); cmbCycle1.DataBindings.Add("SelectedValue", dsSchItems.Tables["ScheduleItems"], "ExtCycleID1"); cmbCycle2.DataBindings.Add("SelectedValue", dsSchItems.Tables["ScheduleItems"], "ExtCycleID2"); cmbAndOr.DataBindings.Add("SelectedItem", dsSchItems.Tables["ScheduleItems"], "AndOr"); //if no schedule items to the selected scheudle then disable all the related selection box
if (lstSchItem.Items.Count<=0) { // cmbServiceItem.SelectedValue = -1; cmbServiceItem.Enabled = false; // cmbCycle1.SelectedValue = -1; cmbCycle1.Enabled = false; // cmbCycle2.SelectedValue = -1; cmbCycle2.Enabled = false; // cmbAndOr.SelectedValue = -1; cmbAndOr.Enabled = false; } else { // lstSchItem.SelectedIndex = 0; ExtServiceItemID = Convert.ToInt32(cmbServiceItem.SelectedValue); ExtCycleID1 = Convert.ToInt32(cmbCycle1.SelectedValue); ExtCycleID2 = Convert.ToInt32(cmbCycle2.SelectedValue); AndOr = cmbAndOr.SelectedItem.ToString(); }
First = false; } catch(Exception ex) { MessageBox.Show("Error binding the database to controls,please contact your support person. : " + ex.ToString() , "VMS - Control datasource error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: raj |
last post by:
Please Help with the combox DisplayValue property
private void cboClient_SelectionChangeCommitted(object sender,
System.EventArgs e)
{
String strSQL;
strSQL = "SELECT F.FollowUpPerson FROM...
|
by: Charles A. Lackman |
last post by:
Hello, I have a combox that I am trying to get to work in the following
fashion.
As you type in the combox that the item that matches what you are type is
selected.
as you type a last name:...
|
by: Alpha |
last post by:
I have a listbox with datasource from a dataview. When a user selects a
different item in a combobox then I need to refresh the listbox to the
appropriate listing based on that combobox's selected...
|
by: Alpha |
last post by:
I have a window application. In one of the form, a datagrid has a dataview
as its datasource. Initial filtering result would give the datavew 3 items.
When I double click on the datagrid to edit...
|
by: PAPutzback |
last post by:
How do I keep the form up.
|
by: A_PK |
last post by:
I have problem databinding the DataGrid with DataView/DataSet after the
filter...
I create the following proceudre in order for user to filter as many as they
want, but the following code is only...
|
by: tfsimes |
last post by:
Hi, I am a long time ASP developer learning .NET, so please bear with
me. I am trying to find an article or such that will help me understand
how to change control properties at runtime based on...
|
by: CCLeasing |
last post by:
Hello, I have searched google but can not find a straight forward
answer to my problem. Hopefuly someone will be kind enough to offer
their expertise. Please forgive if this seems a bit convoluted...
|
by: MariaKhan |
last post by:
?? bind DataSet with listbox ???
?? bind DataSet with listbox ???
?? bind DataSet with listbox ???
?? bind DataSet with listbox ???
?? bind DataSet with listbox ???
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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...
|
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: 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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |