More Group Sites
School Rankings
Jobless Net
Better Home
Enviro++


Help | Subscribe/Unsubscribe | Rules | Other Group Sites: Better Education | Better Education Forum
Welcome Guest Search | Active Topics | Members | Log In | Register

C# how to show enumerated strings in combo boxes in a datagridview Options · View
hong
Posted: Thursday, July 08, 2010 2:30:44 PM

Rank: Administration
Groups: Administration

Joined: 11/23/2008
Posts: 335
Points: 711
Location: Australia
The following code demonstrates how to show the enumerated values in ComboBox in DataGridView:
Code:
        private void UIDlg_Load(object sender, EventArgs e)
        {
            string[] enums = Enum.GetNames(...);

            List<DictionaryEntry> items = new List<DictionaryEntry>();
            foreach (string str in enums)
            {
                items.Add(new DictionaryEntry(items.Count, str));
            }

            comboBoxColumn.DataSource = items;
            comboBoxColumn.ValueMember = "Key";
            comboBoxColumn.DisplayMember = "Value";

            this.myTableAdapter.Fill(this.dataSet.table, ...);

        }


Related: troubleshooting - system.argumentexception: DataGridViewComboBoxCell value is not valid
Sponsor
Posted: Thursday, July 08, 2010 2:30:44 PM
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

ASPNET Theme created by Boskone (Dan Ferguson)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.
This page was generated in 0.432 seconds.