lundi 29 juin 2015

Check ComboBox (Xceed WPF Toolkit), How to get short name to display from database?

This is my first post and I am a relative newbie regarding all things programming related. I hope you will be patient with me. I have a WPF application I am working on. My current issue is a Check ComboBox I am using. When I make selections out of the list that is pulled from a sqlite database file, the full name of the selection is displayed. I would like to change this and have a short name from the database appear in the ComboBox area while leaving the long descriptive name in the dropdown portion. I thought working with display and value member would help out, but have yet to get it working. I can get one or the other by changing the column index reference to my sqlite db. The ComboBox is a multi-select item and it needs to update as selections are made or cleared. Below is the bit of code I have that populates the ComboBox. I am unable to attach an image of the data due to low Rep numbers. Column 0 is the full descriptive name, Column 1 has the short name I am interested in displaying.

public void Fill_Modality()

        {
            SQLiteConnection sqliteCon = new SQLiteConnection(dbConnectionString);
            try
            {
                sqliteCon.Open();
                string Query = "Select * from Modality_list";

                SQLiteCommand createCommand = new SQLiteCommand(Query, sqliteCon);
                SQLiteDataReader dr = createCommand.ExecuteReader();
                while (dr.Read())
                {
                    string modname = dr.GetString(0);
                    Modality_Select.Items.Add(modname);
                }

                dr.Close();
                sqliteCon.Close();
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);

            }
        }

Thank you for any help you may be able to provide.

Patrick

Aucun commentaire:

Enregistrer un commentaire