473,406 Members | 2,404 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,406 software developers and data experts.

view and add sub items of each item of the combo box

myanmaraladin
i recently add two combo boxes in my form. the first combo box contains the categories of movies. and the other one is the list of movies sorted according to the category of movie. i just wondering how i could i add and view movies for the second combo box, when i click one of the category of movie. thank you..
Feb 10 '10 #1
2 3524
tlhintoq
3,525 Expert 2GB
Combobox has a property of .Items that you populate with the things you want it to display.
http://msdn.microsoft.com/en-us/libr....combobox.aspx
Feb 10 '10 #2
lotus18
866 512MB
Hi myanmaraladin,

You can use a nested if-else statement or a select case. Under the SelectedIndexChanged event of your combobox1 (assuming this is your list of categories) try this:

Expand|Select|Wrap|Line Numbers
  1. if combobox1.Text = "Action" Then
  2.      combobox2.Items.Clear()
  3.      combobox2.Items.Add("Action Movie 1")
  4.      combobox2.Items.Add("Action Movie 2")
  5.      combobox2.Items.Add("Action Movie 3")
  6. ElseIf combobox1.Text = "Sci-Fi" Then
  7.      combobox2.Items.Clear()
  8.      combobox2.Items.Add("Avatar")
  9.      combobox2.Items.Add("Transformers")
  10.      combobox2.Items.Add("X-Men")
  11. ElseIf combobox1.Text = "Comedy"
  12.      combobox2.Items.Clear()
  13.      combobox2.Items.Add("Ang Tanging Ina")
  14.      combobox2.Items.Add("Paano Na Kaya?")
  15.      combobox2.Items.Add("Agent X44")
  16. End If
  17.  
Or you can also use AddRange Method
Expand|Select|Wrap|Line Numbers
  1. combobox1.Items.AddRange(New Object() {"Action Movie 1", "Action Movie 2", "Action Movie 3"})

Rey Sean
Feb 10 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Robert W. | last post by:
I'm building my first major C# program and am try to use best practices everywhere. So I've implemented the "Document/View Model" whereby: - There's a Windows Form, which we'll call "formView" -...
2
by: TS | last post by:
Hi all, From my windows form, I opened a connection to a SQL database. Now I need to generate a combo box from a SELECT statement pointing to the last name column in the SQL tables. I am stuck...
3
by: TS | last post by:
Hi all, I posted this question here before, but I'm still having a problem with this code. From my windows form, I opened a connection to a SQL database. I need to generate a combo box in my form...
9
by: Don | last post by:
Is there any way to detect when an item has been added to the Items collection of a combobox or listbox? I am inheriting a Combobox and want to validate items before they are added to the...
2
by: Thief_ | last post by:
I'm using the following code to cycle thru all combo items: Private Sub btEditFavMembers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btEditFavMembers.Click Dim...
0
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another...
3
by: Brian Henry | last post by:
So what is the easiest way to do this? I have one list view with a list of items (in detail view and with about 20 sub items) and a second list view that will take the items they drag from the...
1
by: Gian Paolo | last post by:
hi all i'm looking for a way to add 2 items in a combobox in the same line and hide one. i'm working on the code above but it returns me only the last value i entered and i do not know why.... ...
0
by: Gian Paolo | last post by:
this is something really i can't find a reason. I have a form with a tabcontrol with tree pages, in the second page there is a Data GRid View. Plus i have a class. When i open the form i...
2
by: leopangaribuan | last post by:
hi all, could you please help me? currently i'm working using a view and a table in sql server 2000. the view has a field that sums the quantity of outgoing items grouped by date and then by item...
0
BarryA
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...
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
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...
0
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...
0
agi2029
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,...
0
isladogs
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...

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.