Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8694725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:51:11+00:00 2026-06-13T00:51:11+00:00

Finding the selected item string in a combo box is easy: String selectedString =

  • 0

Finding the selected item string in a combo box is easy:

String selectedString = comboBox1.SelectedItem.ToString();

Finding the selected item index in a combo box is also easy:

int selectedIndex = comboBox1.SelectedIndex; 

But finding the index in a connected database table of the selected item in the combo box doesn’t seem so trivial:

    DataTable dt = new DataTable();
    SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM tblContacts ORDER BY colFirstname", sqlConnection);
    da.Fill(dt);
    for (int i = 0; i < dt.Rows.Count; i++)
    {
        String addressRow = (String)dt.Rows[i]["colFirstname"];
        comboBox1.Items.Add(addressRow);
    }

I could try to somehow derive an index to the DB table from the selected item string, but that doesn’t guarantee uniqueness.

What is the proper way of finding the index in a connected database table of the selected item in the combo box?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:51:12+00:00Added an answer on June 13, 2026 at 12:51 am

    Your combobox selected index is the index in DataTable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am finding the selected jquery tab ui element using the following: $(li.ui-tabs-selected).attr(id) This
How to change color of the selected item from a Xul listbox? I've tried
I'm finding it frustratingly hard to find a simple way to delete my selected
I have a standard com.sun.lwuit.list . I can get the selected item using methods
Finding articles with ANY of a set of tags is a relatively simple join,
For finding the nearest neighbor, Space Partitioning is one of the algorithms. How does
I'm having troubles finding a bad query that's really causing high CPU load due
I am having trouble finding an answer to this. Consider the clipping code below:
Presently Iam working in finding disparity of stereo pair. I have got a situation
I'm finding many articles on the web where it is implied that you can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.