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 8663697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:02:58+00:00 2026-06-12T17:02:58+00:00

I have user data (name, username, image) in a database and I need to

  • 0

I have user data (name, username, image) in a database and I need to list the name and id in a combo box. When an item in the combo box is selected it should display a picture. I have created a User and a UserDB class. In my User class I have the following code:

public class User
  {
    private String u_firstname;
    private String u_lastname;
    private String u_username = string.Empty;
    private Byte [] u_image;
    private Byte [] u_template;


    public User(OleDbDataReader dr)
    {            
        u_firstname = dr["USER_FIRST_NM"].ToString();
        u_lastname = dr["USER_LAST_NM"].ToString();
        u_username = dr["USER_NAME"].ToString();
        u_image = (Byte [])dr["USER_IMAGE"];
        u_template = (Byte [])dr["USER_TEMPLATE"];

    }
}

In my UserDB class I have the following code:

public class UserDB
 {
    public static String workingDirectory = System.IO.Directory.GetCurrentDirectory();
    public static String dbProvider = "Microsoft.ACE.OLEDB.12.0";
    public static String dbName = "Users_DB.accdb";        
    public static String dbConnString = String.Format(@"Provider={0};Data Source={1}\Data\{2}", dbProvider, workingDirectory, dbName);


    public User[] usersInDatabaseList()
    {
        User u;
        List<User> clist = new List<User>();

        OleDbConnection cn = new OleDbConnection(dbConnString);

        String strSQL = "SELECT USER_FIRST_NM, USER_LAST_NM, USER_NAME, USER_IMAGE, USER_TEMPLATE FROM KF001_USERS";

        OleDbCommand cm = new OleDbCommand(strSQL, cn);
        OleDbDataReader dr;

        cn.Open();

        dr = cm.ExecuteReader(CommandBehavior.CloseConnection);

        while (dr.Read())
        {                
            u = new User(dr);
            clist.Add(u);
        }

        cn.Close();


        return clist.ToArray();
    }
}

and on my mainForm I have the following method that I am using for my combo-box:

public void FillDropDownList()
    {
        try
        {

            //int i;
            UserDB db = new UserDB();
            User[] userList = db.usersInDatabaseList();

            comboBoxUsersEnrolled.Items.AddRange(userList);
            comboBoxUsersEnrolled.DisplayMember = ?      
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
}

I am at a total loss as to how to get my database values to be displayed in the combobox. I’m also unsure of how to display a picture when an Item is selected. Can anyone help or steer me in the right direction please.

So I changed filldropdownlist method to the following:

 public void FillDropDownList()
    {

            UserDB db = new UserDB();
            User[] userList = db.cList();



            for (int i = 0; i < userList.Length; i++)
            {

                comboBoxUsersEnrolled.Items.Add(userList[i]);
                comboBoxUsersEnrolled.DisplayMember = "ComboName";




                if (comboBoxUsersEnrolled.SelectedIndex > 0 )
                {

                    byte[] pictureByteReader = (userList[i].UserImage);
                    MemoryStream ms = new MemoryStream(pictureByteReader);
                    Image picture = Image.FromStream(ms);
                    picBoxCapture.Image = picture;
                }

            }


    }

I’m trying to add to my combobox and at the same time send a picture to a picturebox if that item is selected. My code does nothing. Gives no errors or anything. Help!

  • 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-12T17:02:59+00:00Added an answer on June 12, 2026 at 5:02 pm

    You have done most of the work already.

    The DisplayMember property that you’ve marked with ? indicates the property that should be used to display in the ComboBox. Your class doesn’t have any properties – it only has fields – so first you’ll want to create a property

    public class User
    {
        // all your existing fields
    
        public string Name
        {
            get
            {
                return this.u_username;
            }
        }
    

    Then you can set the DisplayMember = "Name"; to use the Name as the display property.

    Using an image requires more work – you will need to use a template in the combobox instead of a string. Try googling that to find an example.

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

Sidebar

Related Questions

I have mail server configuration data (server - user name - password - port)
I have the following scenario: I have various user's data stored in my database.
I have a jQuery grid with data with user data. I need to handle
I have a user that enters a piece of data into my database and
I have checked the user name availability. The problem is, even if the username
I have two databases in CouchDB - DB1's documents are user data - name,
i have form with user data to input and javascript ajax to send information
I'm interested in using a JavaScript Prompt to have the user enter data. Any
I have a simple web application which lets the user upload local user data
I have a User_Id column with data DOMAIN\USERID I need it to be DOMAIN\userid

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.