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.Ad d("SelectedValu e",dvSchItems.T able,
"ExtServiceItem ID");
cmbCycle1.DataB indings.Add("Se lectedValue", dvSchItems.Tabl e,
"ExtCycleID 1");
cmbCycle2.DataB indings.Add("Se lectedValue", dvSchItems.Tabl e,
"ExtCycleID 2");
cmbAndOr.DataBi ndings.Add("Sel ectedItem", dvSchItems.Tabl e, "AndOr");
private void ScheduleItems_L oad(object sender, System.EventArg s e)
{
try
{
cmbScheudle.Dat aSource = dsSchItems.Tabl es["Schedule"];
cmbScheudle.Dis playMember = "ScheduleNa me";
cmbScheudle.Val ueMember = "SchID";
if(cmbScheudle. Items.Count>0)
cmbScheudle.Sel ectedIndex = 0;
else
btnAdd.Enabled = false;
tblSchItems = dsSchItems.Tabl es["ScheduleIt ems"];
dvSchItems.Tabl e = tblSchItems;
if(cmbScheudle. Items.Count>0)
dvSchItems.RowF ilter = FilterExp + cmbScheudle.Sel ectedValue.ToSt ring();
dvSchItems.Sort = SortExp;
// lstSchItem.Data Source = dsSchItems.Tabl es["ScheduleIt ems"];
lstSchItem.Data Source = dvSchItems;
lstSchItem.Disp layMember = "SchItemCod e";
lstSchItem.Valu eMember = "SchItemID" ;
cmbServiceItem. DataSource = dsSchItems.Tabl es["ServiceIte ms"];
cmbServiceItem. DisplayMember = "ServiceNam e";
cmbServiceItem. ValueMember = "ServiceItemID" ;
cmbCycle1.DataS ource = dsSchItems.Tabl es["ServiceCyc le1"];
cmbCycle1.Displ ayMember = "CLU";
cmbCycle1.Value Member = "CycleID";
//Add a blank entry
DataRow BlankCyc2Item = dsSchItems.Tabl es["ServiceCyc le2"].NewRow();
BlankCyc2Item["CycleID"] = -1;
BlankCyc2Item["CLU"] = "";
dsSchItems.Tabl es["ServiceCyc le2"].Rows.Add(Blank Cyc2Item);
dsSchItems.Tabl es["ServiceCyc le2"].AcceptChanges( );
cmbCycle2.DataS ource = dsSchItems.Tabl es["ServiceCyc le2"];
cmbCycle2.Displ ayMember = "CLU";
cmbCycle2.Value Member = "CycleID";
cmbAndOr.Items. Add("");
cmbAndOr.Items. Add("And");
cmbAndOr.Items. Add("Or");
// lstSchItem.Data Bindings.Add("S electedValue",
dsSchItems.Tabl es["Schedule"], "SchID");
cmbServiceItem. DataBindings.Ad d("SelectedValu e",dsSchItems.T ables["ScheduleIt ems"], "ExtServiceItem ID");
cmbCycle1.DataB indings.Add("Se lectedValue",
dsSchItems.Tabl es["ScheduleIt ems"], "ExtCycleID 1");
cmbCycle2.DataB indings.Add("Se lectedValue",
dsSchItems.Tabl es["ScheduleIt ems"], "ExtCycleID 2");
cmbAndOr.DataBi ndings.Add("Sel ectedItem",
dsSchItems.Tabl es["ScheduleIt ems"], "AndOr");
//if no schedule items to the selected scheudle then disable all the
related selection box
if (lstSchItem.Ite ms.Count<=0)
{
// cmbServiceItem. SelectedValue = -1;
cmbServiceItem. Enabled = false;
// cmbCycle1.Selec tedValue = -1;
cmbCycle1.Enabl ed = false;
// cmbCycle2.Selec tedValue = -1;
cmbCycle2.Enabl ed = false;
// cmbAndOr.Select edValue = -1;
cmbAndOr.Enable d = false;
}
else
{
// lstSchItem.Sele ctedIndex = 0;
ExtServiceItemI D = Convert.ToInt32 (cmbServiceItem .SelectedValue) ;
ExtCycleID1 = Convert.ToInt32 (cmbCycle1.Sele ctedValue);
ExtCycleID2 = Convert.ToInt32 (cmbCycle2.Sele ctedValue);
AndOr = cmbAndOr.Select edItem.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",
MessageBoxButto ns.OK, MessageBoxIcon. Error);
}
} 2 1965
Hi,
"Alpha" <Al***@discussi ons.microsoft.c om> wrote in message
news:18******** *************** ***********@mic rosoft.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.Data Source = dvSchItems;
....
cmbServiceItem. DataBindings.Ad d("SelectedValu e", dvSchItems,
"ExtServiceItem ID");
....
HTH,
Greetings
Thank you, Alpha
cmbServiceItem. DataBindings.Ad d("SelectedValu e",dvSchItems.T able, "ExtServiceItem ID"); cmbCycle1.DataB indings.Add("Se lectedValue", dvSchItems.Tabl e, "ExtCycleID 1"); cmbCycle2.DataB indings.Add("Se lectedValue", dvSchItems.Tabl e, "ExtCycleID 2"); cmbAndOr.DataBi ndings.Add("Sel ectedItem", dvSchItems.Tabl e, "AndOr");
private void ScheduleItems_L oad(object sender, System.EventArg s e) {
try { cmbScheudle.Dat aSource = dsSchItems.Tabl es["Schedule"]; cmbScheudle.Dis playMember = "ScheduleNa me"; cmbScheudle.Val ueMember = "SchID"; if(cmbScheudle. Items.Count>0) cmbScheudle.Sel ectedIndex = 0; else btnAdd.Enabled = false;
tblSchItems = dsSchItems.Tabl es["ScheduleIt ems"]; dvSchItems.Tabl e = tblSchItems; if(cmbScheudle. Items.Count>0) dvSchItems.RowF ilter = FilterExp + cmbScheudle.Sel ectedValue.ToSt ring(); dvSchItems.Sort = SortExp;
// lstSchItem.Data Source = dsSchItems.Tabl es["ScheduleIt ems"]; lstSchItem.Data Source = dvSchItems; lstSchItem.Disp layMember = "SchItemCod e"; lstSchItem.Valu eMember = "SchItemID" ;
cmbServiceItem. DataSource = dsSchItems.Tabl es["ServiceIte ms"]; cmbServiceItem. DisplayMember = "ServiceNam e"; cmbServiceItem. ValueMember = "ServiceItemID" ;
cmbCycle1.DataS ource = dsSchItems.Tabl es["ServiceCyc le1"]; cmbCycle1.Displ ayMember = "CLU"; cmbCycle1.Value Member = "CycleID";
//Add a blank entry DataRow BlankCyc2Item = dsSchItems.Tabl es["ServiceCyc le2"].NewRow(); BlankCyc2Item["CycleID"] = -1; BlankCyc2Item["CLU"] = ""; dsSchItems.Tabl es["ServiceCyc le2"].Rows.Add(Blank Cyc2Item); dsSchItems.Tabl es["ServiceCyc le2"].AcceptChanges( ); cmbCycle2.DataS ource = dsSchItems.Tabl es["ServiceCyc le2"]; cmbCycle2.Displ ayMember = "CLU"; cmbCycle2.Value Member = "CycleID";
cmbAndOr.Items. Add(""); cmbAndOr.Items. Add("And"); cmbAndOr.Items. Add("Or");
// lstSchItem.Data Bindings.Add("S electedValue", dsSchItems.Tabl es["Schedule"], "SchID"); cmbServiceItem. DataBindings.Ad d("SelectedValu e",dsSchItems.T ables["ScheduleIt ems"], "ExtServiceItem ID"); cmbCycle1.DataB indings.Add("Se lectedValue", dsSchItems.Tabl es["ScheduleIt ems"], "ExtCycleID 1"); cmbCycle2.DataB indings.Add("Se lectedValue", dsSchItems.Tabl es["ScheduleIt ems"], "ExtCycleID 2"); cmbAndOr.DataBi ndings.Add("Sel ectedItem", dsSchItems.Tabl es["ScheduleIt ems"], "AndOr"); //if no schedule items to the selected scheudle then disable all the related selection box
if (lstSchItem.Ite ms.Count<=0) { // cmbServiceItem. SelectedValue = -1; cmbServiceItem. Enabled = false; // cmbCycle1.Selec tedValue = -1; cmbCycle1.Enabl ed = false; // cmbCycle2.Selec tedValue = -1; cmbCycle2.Enabl ed = false; // cmbAndOr.Select edValue = -1; cmbAndOr.Enable d = false; } else { // lstSchItem.Sele ctedIndex = 0; ExtServiceItemI D = Convert.ToInt32 (cmbServiceItem .SelectedValue) ; ExtCycleID1 = Convert.ToInt32 (cmbCycle1.Sele ctedValue); ExtCycleID2 = Convert.ToInt32 (cmbCycle2.Sele ctedValue); AndOr = cmbAndOr.Select edItem.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", MessageBoxButto ns.OK, MessageBoxIcon. Error);
}
}
I binded them to the dvSchItems.Tabl e. I removed the ".Table" and it works
now. Thank you very much.
Alpha
"Bart Mermuys" wrote: Hi,
"Alpha" <Al***@discussi ons.microsoft.c om> wrote in message news:18******** *************** ***********@mic rosoft.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.Data Source = dvSchItems; .... cmbServiceItem. DataBindings.Ad d("SelectedValu e", dvSchItems, "ExtServiceItem ID"); ....
HTH, Greetings
Thank you, Alpha
cmbServiceItem. DataBindings.Ad d("SelectedValu e",dvSchItems.T able, "ExtServiceItem ID"); cmbCycle1.DataB indings.Add("Se lectedValue", dvSchItems.Tabl e, "ExtCycleID 1"); cmbCycle2.DataB indings.Add("Se lectedValue", dvSchItems.Tabl e, "ExtCycleID 2"); cmbAndOr.DataBi ndings.Add("Sel ectedItem", dvSchItems.Tabl e, "AndOr");
private void ScheduleItems_L oad(object sender, System.EventArg s e) {
try { cmbScheudle.Dat aSource = dsSchItems.Tabl es["Schedule"]; cmbScheudle.Dis playMember = "ScheduleNa me"; cmbScheudle.Val ueMember = "SchID"; if(cmbScheudle. Items.Count>0) cmbScheudle.Sel ectedIndex = 0; else btnAdd.Enabled = false;
tblSchItems = dsSchItems.Tabl es["ScheduleIt ems"]; dvSchItems.Tabl e = tblSchItems; if(cmbScheudle. Items.Count>0) dvSchItems.RowF ilter = FilterExp + cmbScheudle.Sel ectedValue.ToSt ring(); dvSchItems.Sort = SortExp;
// lstSchItem.Data Source = dsSchItems.Tabl es["ScheduleIt ems"]; lstSchItem.Data Source = dvSchItems; lstSchItem.Disp layMember = "SchItemCod e"; lstSchItem.Valu eMember = "SchItemID" ;
cmbServiceItem. DataSource = dsSchItems.Tabl es["ServiceIte ms"]; cmbServiceItem. DisplayMember = "ServiceNam e"; cmbServiceItem. ValueMember = "ServiceItemID" ;
cmbCycle1.DataS ource = dsSchItems.Tabl es["ServiceCyc le1"]; cmbCycle1.Displ ayMember = "CLU"; cmbCycle1.Value Member = "CycleID";
//Add a blank entry DataRow BlankCyc2Item = dsSchItems.Tabl es["ServiceCyc le2"].NewRow(); BlankCyc2Item["CycleID"] = -1; BlankCyc2Item["CLU"] = ""; dsSchItems.Tabl es["ServiceCyc le2"].Rows.Add(Blank Cyc2Item); dsSchItems.Tabl es["ServiceCyc le2"].AcceptChanges( ); cmbCycle2.DataS ource = dsSchItems.Tabl es["ServiceCyc le2"]; cmbCycle2.Displ ayMember = "CLU"; cmbCycle2.Value Member = "CycleID";
cmbAndOr.Items. Add(""); cmbAndOr.Items. Add("And"); cmbAndOr.Items. Add("Or");
// lstSchItem.Data Bindings.Add("S electedValue", dsSchItems.Tabl es["Schedule"], "SchID"); cmbServiceItem. DataBindings.Ad d("SelectedValu e",dsSchItems.T ables["ScheduleIt ems"], "ExtServiceItem ID"); cmbCycle1.DataB indings.Add("Se lectedValue", dsSchItems.Tabl es["ScheduleIt ems"], "ExtCycleID 1"); cmbCycle2.DataB indings.Add("Se lectedValue", dsSchItems.Tabl es["ScheduleIt ems"], "ExtCycleID 2"); cmbAndOr.DataBi ndings.Add("Sel ectedItem", dsSchItems.Tabl es["ScheduleIt ems"], "AndOr"); //if no schedule items to the selected scheudle then disable all the related selection box
if (lstSchItem.Ite ms.Count<=0) { // cmbServiceItem. SelectedValue = -1; cmbServiceItem. Enabled = false; // cmbCycle1.Selec tedValue = -1; cmbCycle1.Enabl ed = false; // cmbCycle2.Selec tedValue = -1; cmbCycle2.Enabl ed = false; // cmbAndOr.Select edValue = -1; cmbAndOr.Enable d = false; } else { // lstSchItem.Sele ctedIndex = 0; ExtServiceItemI D = Convert.ToInt32 (cmbServiceItem .SelectedValue) ; ExtCycleID1 = Convert.ToInt32 (cmbCycle1.Sele ctedValue); ExtCycleID2 = Convert.ToInt32 (cmbCycle2.Sele ctedValue); AndOr = cmbAndOr.Select edItem.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", MessageBoxButto ns.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 tblFollowUpPerson F INNER JOIN
tblFollowUpPersonClient C ON F.FollowUpPersonID = C.FollowUpPersonID WHERE
C.ClientKey = '" + this.cboClient.SelectedValue + "' ";
ds = mg.GetDataSet(strSQL,"userList"); //Def is described at the end
|
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:
Leyman
|
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 value which is included
in the listbox's filtering statement.
Is the only way to do this is to dispose the dataview and then create a new
one and then bind it to the listbox? Is there a better way than this?
Thanks, Alpha
|
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 the selected lie item at which
case I would pop up a separate dialog box to do so, in the debugging code,
the dataview.count would return 0. I get a error message because I tried to
get values out of a dataview that holds 0 items. Does anyone...
|
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 allow user to filter the first time,
when they tried the second time, the speficied cast error message will
prompt one....
I create a mydataset1 first, and the mydataset1 data source was getting from
DataGrid.DataSource.
|
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 the value in a
field.
For instance, if I want to add some text to a field in a GridView based
on a boolean value in an un-shown field being returned.
Another example would be if I want to bind a Listbox to a table of
people, however I want to...
|
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 but this
is probabally a reflection of my not clear understanding of the
mechanics behind what i'm trying to achieve. Please bear with it I
really could do with your help.
I have a simple windows form. There are two controls on the form that I...
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |