资源简介

MultiColumnComboBoxEx(1.2)主要功能:1)下拉框和文本框中显示多列;2)指定显示的列及其顺序;3)设定框高与项高;4)提供Items.IndexOf代替函数ItemIndexOf;5)支持RightToLeft(RTL)。具体实现请参考:http://blog.csdn.net/hulihui/archive/2009/02/01/3856824.aspx。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TestComboBox
{
    public partial class Form1 : Form
    {
        DataTable dataTable;
        Student[] studentArray;
        List studentList;

        public Form1()
        {
            InitializeComponent();
        }

        private void CreateDataSource()
        {
            // Populate using a DataTable

            dataTable = new DataTable(“Employees“);

            dataTable.Columns.Add(“Employee ID“ typeof(string));
            dataTable.Columns.Add(“Name“ typeof(string));
            dataTable.Columns.Add(“Job“ typeof(string));

            dataTable.Rows.Add(new string[] { “D1“ “Natalia“ “Developer“ });
            dataTable.Rows.Add(new string[] { “D2“ “Jonathan“ “Developer“ });
            dataTable.Rows.Add(new string[] { “D3“ “Jake“ “Developer“ });
            dataTable.Rows.Add(new string[] { “D4“ “Abraham“ “Developer“ });
            dataTable.Rows.Add(new string[] { “T1“ “Mary“ “Team Lead“ });
            dataTable.Rows.Add(new string[] { “PM1“ “Calvin“ “Project Manager“ });
            dataTable.Rows.Add(new string[] { “T2“ “Sarah“ “Team Lead“ });
            dataTable.Rows.Add(new string[] { “D12“ “Monica“ “Developer“ });
            dataTable.Rows.Add(new string[] { “D13“ “Donna“ “Developer“ });

            multiColumnComboBoxEx1.DataSource = dataTable;
            multiColumnComboBoxEx1.DisplayMember = “Employee ID“;
            multiColumnComboBoxEx1.ValueMember = “Name“;

            // Populate using a collection

            studentArray = new Student[] 
            { 
                new Student(“Andrew White“ 10) new Student(“Thomas Smith“ 10) new Student(“Alice Brown“ 11)
                new Student(“Lana Jones“ 10) new Student(“Jason Smith“ 9) new Student(“Amamda Williams“ 11)
            };

            multiColumnComboBoxEx2.DataSource = studentArray;
            multiColumnComboBoxEx2.DisplayMember = multiColumnComboBoxEx2.ValueMember = “Name“;

            // Drop-down list (non-editable)

            studentList = new List(studentArray);

            multiColumnComboBoxEx3.DataSource =  studentList;
            multiColumnComboBoxEx3.DisplayMember = “Name“;

            // Trying to use as a regular combobox


            multiColumnComboBoxEx4.Items.Add(“Cat“);
            multiColumnComboBoxEx4.Items.Add(“Tiger“);
            multiColumnComboBoxEx4.Items.Add(“Lion“);
            multiColumnComboBoxEx4.Items.Add(“Cheetah“);
            multiColumnComboBoxEx4.Items.Add(“abcdefghijklmnopqrstuvwxyz“);
            multiColumnComboBoxEx4.SelectedIndex = 0;

        }

        public class Student
        {
            private string name;
            private int age;

            public Student(string name

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2009-01-30 09:45  MultiColumnComboBoxEx\
     目录           0  2009-01-30 09:46  MultiColumnComboBoxEx\bin\
     文件       36864  2009-02-18 23:43  MultiColumnComboBoxEx\bin\MultiColumnComboBoxExDemo.exe
     目录           0  2009-01-30 09:46  MultiColumnComboBoxEx\Properties\
     文件        5612  2009-01-29 17:34  MultiColumnComboBoxEx\Properties\Resources.resx
     文件         249  2009-01-29 17:34  MultiColumnComboBoxEx\Properties\Settings.settings
     文件        2844  2009-01-30 09:47  MultiColumnComboBoxEx\Properties\Resources.Designer.cs
     文件        1108  2009-01-30 09:47  MultiColumnComboBoxEx\Properties\Settings.Designer.cs
     文件        1269  2009-01-31 08:49  MultiColumnComboBoxEx\Properties\AssemblyInfo.cs
     文件       31150  2009-02-18 23:44  MultiColumnComboBoxEx\MultiColumnComboBoxEx.cs
     文件         473  2009-01-30 13:58  MultiColumnComboBoxEx\Program.cs
     文件       12155  2009-02-18 23:43  MultiColumnComboBoxEx\Form1.designer.cs
     文件        5486  2009-02-18 23:43  MultiColumnComboBoxEx\Form1.cs
     文件         423  2009-02-07 09:29  MultiColumnComboBoxEx\ClassDiagram1.cd
     文件        5814  2009-02-18 23:43  MultiColumnComboBoxEx\Form1.resx
     文件       21504  2009-02-18 23:44  MultiColumnComboBoxEx\MultiColumnComboBoxExDemo.suo
     文件         938  2009-01-31 08:49  MultiColumnComboBoxEx\MultiColumnComboBoxExDemo.sln
     文件        3467  2009-02-06 16:22  MultiColumnComboBoxEx\MultiColumnComboBoxExDemo.csproj

评论

共有 条评论