473,738 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cascading combobox

I have 2 bound ComboBoxes. I want the datasource of the second to be limited
by the selection made in the first. I can do this by responding to the
SelectionIndexC hanged event on the first, but this results in the
BindingContext' s Current.Row.Row state becoming 'Modified' whenever the
BindingContext position changes. What is the RIGHT way to go about this?

Thanks,
--
Pat
Nov 21 '05 #1
4 7823
Hi,

Bind the second combobox to a dataview. Use the dataview.rowfil ter
method to only show the right records.

Ken
---------------
"pmcguire" <pm******@discu ssions.microsof t.com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
I have 2 bound ComboBoxes. I want the datasource of the second to be
limited
by the selection made in the first. I can do this by responding to the
SelectionIndexC hanged event on the first, but this results in the
BindingContext' s Current.Row.Row state becoming 'Modified' whenever the
BindingContext position changes. What is the RIGHT way to go about this?

Thanks,
--
Pat
Nov 21 '05 #2
Hmm. I don't really understand.

You mean use a filtered DataView as the second ComboBox's DataSource? I am
already doing that. The problem isn't obtaining the list of values needed
for the ComboBox, the problem is that I want to bind the SelectedValue of the
two ComboBoxes to columns in another table. When PositionChanged fires,
Combo1 and Combo2 both get new values; however, in general, the value Combo2
gets from its currency manager is not yet present in its list, so after
Combo1_Selectio nIndexChanged fires (somewhat later) and Combo2 synchs up, the
BindingContext interprets Combo2 as having modified the record.

Forgive me if I'm being dense, but does your solution solve this? And if
so, could you show me an example of how to do what you are describing?

Thanks,

Pat
"Ken Tucker [MVP]" wrote:
Hi,

Bind the second combobox to a dataview. Use the dataview.rowfil ter
method to only show the right records.

Ken
---------------
"pmcguire" <pm******@discu ssions.microsof t.com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
I have 2 bound ComboBoxes. I want the datasource of the second to be
limited
by the selection made in the first. I can do this by responding to the
SelectionIndexC hanged event on the first, but this results in the
BindingContext' s Current.Row.Row state becoming 'Modified' whenever the
BindingContext position changes. What is the RIGHT way to go about this?

Thanks,
--
Pat

Nov 21 '05 #3
Hi,

Dim ds As New DataSet

Dim dv As DataView

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim conn As SqlConnection

Dim strConn As String

Dim strCmd As String

Dim da, daProducts As SqlDataAdapter

Dim strServer As String = "(local)"

strConn = String.Format(" Server = {0};", strServer)

strConn &= "Database = Northwind; Integrated Security = sspi;"

conn = New SqlConnection(s trConn)

da = New SqlDataAdapter( "Select * From Categories", conn)

da.Fill(ds, "Categories ")

daProducts = New SqlDataAdapter( "Select * from Products", conn)

daProducts.Fill (ds, "Products")

dv = New DataView(ds.Tab les("Products") )

With cmbCategories

..DataSource = ds.Tables("Cate gories")

..DisplayMember = "CategoryNa me"

..ValueMember = "CategoryID "

End With

With cmbProducts

..DataSource = dv

..DisplayMember = "ProductNam e"

End With

End Sub

Private Sub cmbCategories_S electedValueCha nged(ByVal sender As Object, ByVal
e As System.EventArg s) Handles cmbCategories.S electedValueCha nged

Try

dv.RowFilter = "CategoryID = " & cmbCategories.S electedValue.To String

Catch

End Try

End Sub

Ken

------------------------------

"pmcguire" <pm******@discu ssions.microsof t.com> wrote in message
news:94******** *************** ***********@mic rosoft.com...
Hmm. I don't really understand.

You mean use a filtered DataView as the second ComboBox's DataSource? I am
already doing that. The problem isn't obtaining the list of values needed
for the ComboBox, the problem is that I want to bind the SelectedValue of
the
two ComboBoxes to columns in another table. When PositionChanged fires,
Combo1 and Combo2 both get new values; however, in general, the value Combo2
gets from its currency manager is not yet present in its list, so after
Combo1_Selectio nIndexChanged fires (somewhat later) and Combo2 synchs up,
the
BindingContext interprets Combo2 as having modified the record.

Forgive me if I'm being dense, but does your solution solve this? And if
so, could you show me an example of how to do what you are describing?

Thanks,

Pat
"Ken Tucker [MVP]" wrote:
Hi,

Bind the second combobox to a dataview. Use the
dataview.rowfil ter
method to only show the right records.

Ken
---------------
"pmcguire" <pm******@discu ssions.microsof t.com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
I have 2 bound ComboBoxes. I want the datasource of the second to be
limited
by the selection made in the first. I can do this by responding to the
SelectionIndexC hanged event on the first, but this results in the
BindingContext' s Current.Row.Row state becoming 'Modified' whenever the
BindingContext position changes. What is the RIGHT way to go about this?

Thanks,
--
Pat

Nov 21 '05 #4
Hi Ken,

Thanks for taking the time and I'm sorry it has taken me so long to respond.

OK, I'm cool with your example as far as it goes, but let's add the final
piece:

Let's say you have a third table, MyTable, with 2 DataColumns, "Category"
and "Product" and you want to do the following,

cmbCategories.D ataBindings.Add (New Binding("Select edValue", ds,
"MyTable.Catego ry"))
cmbProducts.Dat aBindings.Add(N ew Binding("Select edValue", ds,
"MyTable.Produc t"))

mCMA=DirectCast (Me.BindingCont ext(ds,"MyTable "),CurrencyMana ger)

How do you ensure that mCMA.Current.Ro w.RowState<>Mod ified after mCMA's
position changes? I should point out that my particular application is now
working, but that I have no idea why.

Thanks again,

Pat
"Ken Tucker [MVP]" wrote:
Hi,

Dim ds As New DataSet

Dim dv As DataView

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim conn As SqlConnection

Dim strConn As String

Dim strCmd As String

Dim da, daProducts As SqlDataAdapter

Dim strServer As String = "(local)"

strConn = String.Format(" Server = {0};", strServer)

strConn &= "Database = Northwind; Integrated Security = sspi;"

conn = New SqlConnection(s trConn)

da = New SqlDataAdapter( "Select * From Categories", conn)

da.Fill(ds, "Categories ")

daProducts = New SqlDataAdapter( "Select * from Products", conn)

daProducts.Fill (ds, "Products")

dv = New DataView(ds.Tab les("Products") )

With cmbCategories

..DataSource = ds.Tables("Cate gories")

..DisplayMember = "CategoryNa me"

..ValueMember = "CategoryID "

End With

With cmbProducts

..DataSource = dv

..DisplayMember = "ProductNam e"

End With

End Sub

Private Sub cmbCategories_S electedValueCha nged(ByVal sender As Object, ByVal
e As System.EventArg s) Handles cmbCategories.S electedValueCha nged

Try

dv.RowFilter = "CategoryID = " & cmbCategories.S electedValue.To String

Catch

End Try

End Sub

Ken

------------------------------

"pmcguire" <pm******@discu ssions.microsof t.com> wrote in message
news:94******** *************** ***********@mic rosoft.com...
Hmm. I don't really understand.

You mean use a filtered DataView as the second ComboBox's DataSource? I am
already doing that. The problem isn't obtaining the list of values needed
for the ComboBox, the problem is that I want to bind the SelectedValue of
the
two ComboBoxes to columns in another table. When PositionChanged fires,
Combo1 and Combo2 both get new values; however, in general, the value Combo2
gets from its currency manager is not yet present in its list, so after
Combo1_Selectio nIndexChanged fires (somewhat later) and Combo2 synchs up,
the
BindingContext interprets Combo2 as having modified the record.

Forgive me if I'm being dense, but does your solution solve this? And if
so, could you show me an example of how to do what you are describing?

Thanks,

Pat
"Ken Tucker [MVP]" wrote:
Hi,

Bind the second combobox to a dataview. Use the
dataview.rowfil ter
method to only show the right records.

Ken
---------------
"pmcguire" <pm******@discu ssions.microsof t.com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
I have 2 bound ComboBoxes. I want the datasource of the second to be
limited
by the selection made in the first. I can do this by responding to the
SelectionIndexC hanged event on the first, but this results in the
BindingContext' s Current.Row.Row state becoming 'Modified' whenever the
BindingContext position changes. What is the RIGHT way to go about this?

Thanks,
--
Pat


Nov 21 '05 #5

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

Similar topics

0
1805
by: Humpty Dumpty | last post by:
Hi folks, here's a challenge: I have a dynamically created cascading menu in Tkinter that can be quite large because it is created from a file. I tried using lazy creation so only the menu item that is actually selected by the user gets children menu items created under it, but that fails. I did this by use of postcommand callback, in which I dynamically add the children menu items to the parent. However, a print statement in the...
1
2016
by: JMosey | last post by:
Not sure if this has been covered ( a google search came up pretty bare). I have a site that: - has multi-level cascading menus - floats center of the browser window - Will have fairly heavy Safari and Firefox views (~25%) Finding a cascading menu is easy, I trip over about half a dozen of those a week. The problem is when you maximize on a big screen in
9
6761
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the second combo to change depending on what values the user selects in the first box, it's just that every time the user changes the first combobox, the second combobox FOR EVERY RECORD goes blank.
6
2086
by: visionstate | last post by:
Hi there, I am building a database that requires cascading lists on a form. I currently have (I may be adding more later) 3 combo boxes on my form - Department, Surname and Forename. The user chooses the department they want and then the corresponding surnames from that department can be chosen from the Surname box and then the Forename depending on which Surname they chose. I then have a command button which produces the results of the...
1
1934
by: wizardRahl | last post by:
Hello all, I am fairly new to Access. I have a decent understanding of database concepts from working with sql developer and Oracle's APEX. In MS access, I would like to know how to populate a list from a list of values (maybe a combobox in Access?) On my form, I have a combobox that has values from a "Letters" table, which is A-Z. I would like to know how to populate a listbox/combobox to retreive Employees names (Last name, First, name)...
3
1640
by: tcveltma | last post by:
Hi Everyone, I have a cascading combo box, where you choose a general topic, and the next combo box only shows the related options....easy. Now I'm being told that one of the options I have can only be visible when a different combo box has a certain option. The table I am drawing form is not really set up to add to my SELECT statement, so I'm basically looking for a code along the lines of Forms!FormName!ComboBox.ItemData(0).Visible =...
19
2323
by: Amanduh | last post by:
Hi again, brilliant developers. I'm having serious issues with cascading comboboxes. I had it working perfectly before, but then was asked to add an additional variable and everything went haywire (surely due to my incompetence). I've printed out Rabbit's tutorial and read it many times, but like others, I feel I need a more elementary approach. Please let me explain: I'm creating a database for entering information for research studies. ...
4
3495
klarae99
by: klarae99 | last post by:
Hello, I am working on an Access 2003 Database. The tables that pertain to this issue are tblOrg, tblState, tblCity, and tblZip. I have posted the table structure with only the pertinant fields below. tblOrg OrgID, AutoNumber, PK ZipID, Number, FK tblState StateID, AutoNumber, PK
6
2918
Walt in Decatur
by: Walt in Decatur | last post by:
I have implemented successfully a single-cascade ComboBox combination on a form in my database (using an AfterUpdate event code). I have also successfully implemented a ComboBox + TextBox combination, whereby the TextBox shows contents of another column from the query for the ComboBox. It's when I try to link these two up together when the problem comes up. I've been trying to find a solution to this coding problem in a practice unbound...
0
8968
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9473
Oralloy
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...
0
9334
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 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...
1
9259
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,...
0
9208
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6053
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();...
0
4569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4824
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.