How to write a code for selected item in a combo box | Bytes (2024)

rhepsi

How to write a code for selected item in a combo box | Bytes (1) 111 New Member

hii all,

for selecting one item in a combo box n writing a search button_click code for that....

There are 3 items in teh combobox, nw for 1 item i want to write a code for search_button click

How to start with

If combobox = Project Manager Then........... .....>> error

wat shd i consider...

plz someone help...

thnx

Jul 5 '07

Subscribe Reply

14 How to write a code for selected item in a combo box | Bytes (2) 2459 How to write a code for selected item in a combo box | Bytes (3)

  • <
  • 1
  • 2
You want to list the projectcode and projectlocation for the projectmanager you selected in the Combobox2.Is this right?

If yes,give your table_staff,tab le_staff_assign ment,table_proj ect structures(fiel ds present in the table)

sample query:

select C.ID,C.ProjectC ode,C.ProjectLo cation,C.Projec tName from tbl_staff A
left join tbl_staff _assignments B on B.StaffID=A.ID
left join tbl_projects C on C.ID=B.projectI D
where A.Name=(combobo x.selecteditem)

thnq so much... i shall try tht code... n give u reply...

Jul 6 '07 #11

reply

rhepsi

111 How to write a code for selected item in a combo box | Bytes (5) New Member

You want to list the projectcode and projectlocation for the projectmanager you selected in the Combobox2.Is this right?

If yes,give your table_staff,tab le_staff_assign ment,table_proj ect structures(fiel ds present in the table)

sample query:

select C.ID,C.ProjectC ode,C.ProjectLo cation,C.Projec tName from tbl_staff A
left join tbl_staff _assignments B on B.StaffID=A.ID
left join tbl_projects C on C.ID=B.projectI D
where A.Name=(combobo x.selecteditem)

Hey ive tried it.... but of no use...
here is my code:

Expand|Select|Wrap|Line Numbers

  1. 'GetPrimaryKeyfromListbox
  2. objListItem=CType(cbPrSearchList.SelectedItem,ListItem)
  3. cmSQL=NewMySqlCommand
  4. DimmySelectQueryAsString="Selectpr_project_id_pk,pr_project_code,"_
  5. &"pr_project_location,pr_project_manager_id_fk,pr_street_address,"_
  6. &"pr_state_id_fk,pr_pincode,pr_postal_address,pr_phone,"_
  7. &"pr_courier_service,pr_email,pr_om_field,pr_total_students,pr_total_staff,"_
  8. &"pr_teaching_staff,pr_non_teaching_staff,pr_project_background,"_
  9. &"pr_profile_status,pr_photo_status,pr_upload_status,pr_comm_history"_
  10. &"fromtbl_staffsINNERJOINtbl_staff_assignmentsONtbl_staff_assignments.sta_staff_id_fk=tbl_staffs.stf_staff_id_pk"_
  11. &"INNERJOINtbl_projectsONtbl_projects.pr_project_id_pk=tbl_staff_assignments.sta_project_id_fk"_
  12. &"WHEREtbl_staff_assignments.sta_project_id_fk=?StId"
  13. cmSQL.Parameters.Add("?StId",objListItem.ID)
  14. cnSQL=NewMySqlConnection
  15. cnSQL.ConnectionString=connect.ConnectionString
  16. cmSQL.Connection=cnSQL
  17. cmSQL.CommandText=mySelectQuery

Its takingdirectly the project_id from tbl_projects not from tbl_staff_assig nments project_id...

plz if u can help me...

Jul 9 '07 #12

reply

rhepsi

111 How to write a code for selected item in a combo box | Bytes (6) New Member

Hey ive tried it.... but of no use...
here is my code:

Expand|Select|Wrap|Line Numbers

  1. 'GetPrimaryKeyfromListbox
  2. objListItem=CType(cbPrSearchList.SelectedItem,ListItem)
  3. cmSQL=NewMySqlCommand
  4. DimmySelectQueryAsString="Selectpr_project_id_pk,pr_project_code,"_
  5. &"pr_project_location,pr_project_manager_id_fk,pr_street_address,"_
  6. &"pr_state_id_fk,pr_pincode,pr_postal_address,pr_phone,"_
  7. &"pr_courier_service,pr_email,pr_om_field,pr_total_students,pr_total_staff,"_
  8. &"pr_teaching_staff,pr_non_teaching_staff,pr_project_background,"_
  9. &"pr_profile_status,pr_photo_status,pr_upload_status,pr_comm_history"_
  10. &"fromtbl_staffsINNERJOINtbl_staff_assignmentsONtbl_staff_assignments.sta_staff_id_fk=tbl_staffs.stf_staff_id_pk"_
  11. &"INNERJOINtbl_projectsONtbl_projects.pr_project_id_pk=tbl_staff_assignments.sta_project_id_fk"_
  12. &"WHEREtbl_staff_assignments.sta_project_id_fk=?StId"
  13. cmSQL.Parameters.Add("?StId",objListItem.ID)
  14. cnSQL=NewMySqlConnection
  15. cnSQL.ConnectionString=connect.ConnectionString
  16. cmSQL.Connection=cnSQL
  17. cmSQL.CommandText=mySelectQuery
Its takingdirectly the project_id from tbl_projects not from tbl_staff_assig nments project_id...

plz if u can help me...

Im getting this error

Dim mySelectQuery As String = "Select pr_project_id_p k, pr_project_code ," _
& "pr_project_loc ation, pr_project_mana ger_id_fk, pr_street_addre ss, " _
& "pr_state_id_fk , pr_pincode, pr_postal_addre ss, pr_phone, " _
& "pr_courier_ser vice, pr_email, pr_om_field, pr_total_studen ts, pr_total_staff, " _
& "pr_teaching_st aff, pr_non_teaching _staff, pr_project_back ground, " _
& "pr_profile_sta tus, pr_photo_status , pr_upload_statu s, pr_comm_history , " _
& "pr_cs_comments , pr_lkg, pr_ukg, pr_class01, pr_class02, pr_class03, " _
& "pr_class04 , pr_class05, pr_class06, pr_class07, pr_class08, pr_class09, " _
& "pr_class10 , pr_year_started , pr_land_status, pr_building_sta tus, " _
& "pr_ann_op_cost , pr_project_rema rks, pr_info_date, pr_isactive " _
& "FROM tbl_staffs LEFT JOIN tbl_staff_assig nments ON tbl_staff_assig nments.sta_staf f_id_fk = tbl_staffs.stf_ staff_id_pk " _
& "LEFT JOIN tbl_projects ON tbl_projects.pr _project_id_pk = tbl_staff_assig nments.sta_proj ect_id_fk " _
& "WHERE tbl_staffs.stf_ first_name = ?SID "

cmSQL.Parameter s.Add("?SID", objListItem.ID)

General Error

Cast from string "" to type 'Double' is not valid.

Jul 9 '07 #13

reply

Vidhura

99 How to write a code for selected item in a combo box | Bytes (7) New Member

Im getting this error

Dim mySelectQuery As String = "Select pr_project_id_p k, pr_project_code ," _
& "pr_project_loc ation, pr_project_mana ger_id_fk, pr_street_addre ss, " _
& "pr_state_id_fk , pr_pincode, pr_postal_addre ss, pr_phone, " _
& "pr_courier_ser vice, pr_email, pr_om_field, pr_total_studen ts, pr_total_staff, " _
& "pr_teaching_st aff, pr_non_teaching _staff, pr_project_back ground, " _
& "pr_profile_sta tus, pr_photo_status , pr_upload_statu s, pr_comm_history , " _
& "pr_cs_comments , pr_lkg, pr_ukg, pr_class01, pr_class02, pr_class03, " _
& "pr_class04 , pr_class05, pr_class06, pr_class07, pr_class08, pr_class09, " _
& "pr_class10 , pr_year_started , pr_land_status, pr_building_sta tus, " _
& "pr_ann_op_cost , pr_project_rema rks, pr_info_date, pr_isactive " _
& "FROM tbl_staffs LEFT JOIN tbl_staff_assig nments ON tbl_staff_assig nments.sta_staf f_id_fk = tbl_staffs.stf_ staff_id_pk " _
& "LEFT JOIN tbl_projects ON tbl_projects.pr _project_id_pk = tbl_staff_assig nments.sta_proj ect_id_fk " _
& "WHERE tbl_staffs.stf_ first_name = ?SID "

cmSQL.Parameter s.Add("?SID", objListItem.ID)

General Error

Cast from string "" to type 'Double' is not valid.

& "WHERE tbl_staffs.stf_ first_name = ?SID "

cmSQL.Parameter s.Add("?SID", objListItem.ID)

what the objectlistItem. ID contains?either staffname or ID

If you connecting with ID

use
& "WHERE tbl_staffs.ID= ?SID "

Jul 9 '07 #14

reply

rhepsi

111 How to write a code for selected item in a combo box | Bytes (8) New Member

& "WHERE tbl_staffs.stf_ first_name = ?SID "

cmSQL.Parameter s.Add("?SID", objListItem.ID)

what the objectlistItem. ID contains?either staffname or ID

If you connecting with ID

use
& "WHERE tbl_staffs.ID= ?SID "

hey thnq so much... its workin nw...

Jul 9 '07 #15

reply

  • <
  • 1
  • 2

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

Similar topics

1 3462

Subform won't show data selected from Combo Box

by: Donna Sabol |last post by:

I have a form (frm_MAIN_RPT) that contains a combo box (Combo6) & subform (dbo_REQ_subform). The combo box is used to select the "cost center" data that will be displayed in the subform. From there, I have a button that runs a report based on which item I select in the subform. 1. The Combo Box correctly displays the list of cost centers within the combo box. 2. The subform, when opened separately, correctly displays the data for the...

Microsoft Access / VBA

1 2031

How to test if an item has been selected of a combo box

by: ree |last post by:

I have two combo boxes on a dialog window. The aim is to check the the strings of the items. But if no items are selected then this line crashes the program. if (comboBox1.SelectedItem.ToString() == comboBox2.SelectedItem.ToString()) -- Is there a way to test if an item has been selected. So then i can run the

C# / C Sharp

2 5802

HtmlSelect populated dynamically, fails to return selected item

by: Stephen Miller |last post by:

When I dynamically populate a HtmlSelect combo box, the Value property consistently fails to return the item selected, defaulting instead to the first item in the list. For example: Protected WithEvents Fruits As System.Web.UI.HtmlControls.HtmlSelect Protected WithEvents Results As System.Web.UI.WebControls.Label Protected WithEvents Button1 As System.Web.UI.WebControls.Button … Private Sub Page_Load(ByVal sender As System.Object, ByVal...

ASP.NET

1 2356

Working Code of Bound dropdownlist in Datagrid

by: jimb |last post by:

I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .. http://sf-f.org, weblog and search engine for fans and writers of

Visual Basic .NET

2 2382

Simple combobox question on text and selected value

by: Brian Henry |last post by:

say I have a databound combo box, which allows for text entry still (DropDownStype = DropDown in this case). now, If the user doesn't enter manually an item in the data bound list, nothing should be selected of course, but I want if a user enters an item that is in the list already, to select it, and only if the item is a complete match to what they typed to be selected. This is kind of like an auto complete scenerio, but allows for...

Visual Basic .NET

6 5181

setting selected item of a combo box filled with objects

by: Smokey Grindle |last post by:

Say I have a combo box with the following simple object Public class MyObject public ID as integer public Name as string public overrides sub ToString() as string return name end sub end Class

Visual Basic .NET

16 2977

Display the selected item

by: Ranjan kumar Barik |last post by:

Hello !!! I am Ranjan. can the selected item of a combo box be displayed on the same page. I mean when I just click the item of a combo box it will atonce displayed on the page. Thanks !!!

ASP / Active Server Pages

14 1756

What's the VB9 equivalent for this code

by: Just_a_fan |last post by:

In VB6, I could easily take the value from a combo box and make a command with it, this: baudrate = cboBaud(listindex). With the new dotted stuff in VB9, I can't seem to do that. Here's an example of my problem. I have a combo box with various baud rates in it. The user selects one and I want to use it. However, the command to use it is in the format:

Visual Basic .NET

8 1648

making a combo box display a value from its list via code?

by: ZaphodBBB |last post by:

Hi I have a form frmAdd_Equipment. It has a number of combo boxes on it, cboModel, cboSupplier, cboManufacturer, cboEquipment_Type etc. Bcause therer is no existing data to go off I put an ADD NEW cmdButton next to each of the ComboBoxes so if the item does not exist then the user can add a new Model, Supplier etc. The various ComboBoxes all load from Queries when the Form Loads. What I'd like to do, is to make it so that should the...

Microsoft Access / VBA

7993

What is ONU?

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...

General

7920

Changing the language in Windows 10

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,...

Windows Server

1 8054

The easy way to turn off automatic updates for Windows 10/11

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,...

Windows Server

8268

Discussion: How does Zigbee compare with other wireless protocols in smart home applications?

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...

General

1 5867

Access Europe - Using VBA to create a class based on a table - Wed 1 May

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...

Microsoft Access / VBA

3944

Windows Forms - .Net 8.0

by: adsilva |last post by:

A Windows Forms form does not have the event Unload, like VB6. What one acts like?

Visual Basic .NET

1 2418

transfer the data from one system to another through ip address

by: 6302768590 |last post by:

Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

C# / C Sharp

1 1510

How to add payments to a PHP MySQL app.

by: muto222 |last post by:

How can i add a mobile payment intergratation into php mysql website.

PHP

1254

Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy

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...

General

How to write a code for selected item in a combo box | Bytes (2024)

FAQs

How do I get the selected item in a ComboBox? ›

Value of the selected item can be retrieved by using the SelectedValue property. It returns the property value bind to the ValueMember property. If the ValueMember is not initialized, it will return the value of the property bind to DisplayMember.

How to set selected items in ComboBox in JavaScript? ›

var selectedCli = $("#txCodigoCli"). val(); comoBox3. selectedValue = selectedCli //if selectedCli is not in the current page, it should be retreived from the server to display the name corresponding to the code.

How do you add items to a ComboBox in code? ›

To add items
  1. Add the string or object to the list by using the Add method of the ObjectCollection class. The collection is referenced using the Items property: C# Copy. ...
  2. Insert the string or object at the desired point in the list with the Insert method: C# Copy. ...
  3. Assign an entire array to the Items collection: C# Copy.
Feb 6, 2023

What is the selected item property in ComboBox? ›

When you set the SelectedItem property to an object, the ComboBox attempts to make that object the currently selected one in the list. If the object is found in the list, it is displayed in the edit portion of the ComboBox and the SelectedIndex property is set to the corresponding index.

How do I get the selected item in a dropdown? ›

Using the value property

The value of the selected element can be found by using the value property on the selected element that defines the list. This property returns a string representing the value attribute of the <option> element in the list. If no option is selected then nothing will be returned.

How to get ComboBox selected value in Python? ›

PyQt5 – Getting the text of selected item in ComboBox
  1. Syntax : combo_box.currentText()
  2. Argument : It takes no argument.
  3. Return : It return string.
Jan 19, 2023

How to get selected value in select box using JavaScript? ›

Here's an example:
  1. // HTML.
  2. Option 1.
  3. Option 2.
  4. Option 3.
  5. // JavaScript.
  6. const dropdown = document. getElementById("myDropdown"
  7. const selectedOption = dropdown. options[dropdown. selectedIndex.
  8. const selectedValue = selectedOption. value;
Nov 25, 2023

How to set RadComboBox selected value in JavaScript? ›

To set it's SelectedIndex property to 0 you call the set_selectedIndex() function on the client-side control. Keep in mind that this only sets the SelectedIndex, and does not update the text in the input field of the RadComboBox .

How to add items to ComboBox in JavaScript? ›

add(new Option("", "", true, true), 0) //add blank option to beginning of starthour frm. startminute. add(new Option("", "", true, true), 0) frm. endhour.

How do you implement a ComboBox? ›

Insert a combo box
  1. On the form template, place the cursor where you want to insert the control.
  2. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.
  3. In the Controls task pane, do one of the following: ...
  4. Under Insert controls, click Combo Box.

How many items can be added to a ComboBox? ›

The ComboBox can easily contain thousands of items. The 100 limit you are referring to is the visible portion which is displayed when the ComboBox drop down appears.

What is the difference between selected value and selected item in ComboBox? ›

The SelectedItem property represents an object in the Items collection and the combo box displays the value of a single property of the selected item. The SelectedValuePath property specifies the path to the property that is used to determine the value of the SelectedValue property.

What is selected index in ComboBox? ›

Gets or sets the index of the selected ComboBox item. This index specifies the item position inside the RepositoryItemComboBox. Items collection.

How do I select multiple values in select ComboBox? ›

1 Answer. You can use CheckBox as the Items of ComboBox . And when the CheckBox is checked, it is important to modify the PlaceholderText of ComboBox , by default it will show the selected Item, but we can modify it to show all the items which is checked.

How to get value from a ComboBox? ›

To access the selected value from the combobox, you either need to pass the combobox itself to the method, or pass the selected value to the method. A method cannot access things which it doesn't know about, either as parameters to the method or as fields or properties on the containing class.

How to get selected items from ListBox? ›

To determine the items that are selected, you can use the Selected property of the list box. The Selected property of a list box is an array of values where each value is either True (if the item is selected) or False (if the item is not selected).

How do I get the index of a ComboBox selection? ›

Get Index Of Selected Value (ComboBoxCell) Search the cell value (Cell. Value) in the ComboBox. Items property collection to get the index of the value selected in the combo box cell.

How to check what is selected in a ComboBox Java? ›

You can use JComboBox#getSelectedIndex , which will return -1 if nothing is selected or JComboBox#getSelectedItem which will return null if nothing is selected.

References

Top Articles
Latest Posts
Article information

Author: Trent Wehner

Last Updated:

Views: 5987

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Trent Wehner

Birthday: 1993-03-14

Address: 872 Kevin Squares, New Codyville, AK 01785-0416

Phone: +18698800304764

Job: Senior Farming Developer

Hobby: Paintball, Calligraphy, Hunting, Flying disc, Lapidary, Rafting, Inline skating

Introduction: My name is Trent Wehner, I am a talented, brainy, zealous, light, funny, gleaming, attractive person who loves writing and wants to share my knowledge and understanding with you.