当前位置: 首页>>代码示例>>C#>>正文


C# ComboBox类代码示例

本文整理汇总了C#中ComboBox的典型用法代码示例。如果您正苦于以下问题:C# ComboBox类的具体用法?C# ComboBox怎么用?C# ComboBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ComboBox类属于命名空间,在下文中一共展示了ComboBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

    public override Widget Create(object caller)
    {
        HBox box = new HBox();

        PropertiesView propview = (PropertiesView)caller;

        // Add the names of the sectors to a list
        sectorNames = new List<String>(propview.application.CurrentLevel.Sectors.Count);
        foreach(Sector sector in propview.application.CurrentLevel.Sectors) {
            sectorNames.Add(sector.Name);
        }

        // Populate a combo box with the sector names
        comboBox = new ComboBox(sectorNames.ToArray());

        OnFieldChanged(Field); //same code for initialization

        comboBox.Changed += OnComboBoxChanged;
        box.PackStart(comboBox, true, true, 0);

        box.Name = Field.Name;

        CreateToolTip(caller, comboBox);

        return box;
    }
开发者ID:Karkus476,项目名称:supertux-editor,代码行数:26,代码来源:ChooseSectorWidget.cs

示例2: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    { 
        ComboBox1 = new ComboBox();
        ComboBox1.ID = "ComboBox1";
        ComboBox1.Width = Unit.Pixel(250);
        ComboBox1.EmptyText = "Select a customer ...";
        ComboBox1.DataSourceID = "sds1"; 
        ComboBox1.DataTextField = "CompanyName";
        ComboBox1.DataValueField = "CustomerID";
        ComboBox1.FolderStyle = "styles/black_glass";

        ComboBoxContainer1.Controls.Add(ComboBox1);

        ComboBox2 = new ComboBox();
        ComboBox2.ID = "ComboBox2";
        ComboBox2.Width = Unit.Pixel(250);
        ComboBox2.EmptyText = "Select a customer ...";
        ComboBox2.DataSourceID = "sds1";
        ComboBox2.DataTextField = "CompanyName";
        ComboBox2.DataValueField = "CustomerID";
        ComboBox2.FolderStyle = "_";

        ComboBoxContainer2.Controls.Add(ComboBox2);

        ComboBox3 = new ComboBox();
        ComboBox3.ID = "ComboBox3";
        ComboBox3.Width = Unit.Pixel(250);
        ComboBox3.EmptyText = "Select a customer ...";
        ComboBox3.DataSourceID = "sds1";
        ComboBox3.DataTextField = "CompanyName";
        ComboBox3.DataValueField = "CustomerID";
        ComboBox3.FolderStyle = "_";
  
        ComboBoxContainer3.Controls.Add(ComboBox3);
    }
开发者ID:veraveramanolo,项目名称:power-show,代码行数:35,代码来源:cs_different_styles.aspx.cs

示例3: OnListItemUnselected

 void OnListItemUnselected(ComboBox.ComboItem unselectedItem)
 {
     if (selectedHost == (HostData)unselectedItem.value)
     {
         selectedHost = null;
     }
 }
开发者ID:niguerrac,项目名称:UnityUI,代码行数:7,代码来源:MasterServerInterface.cs

示例4: Calendar1_DayRender

    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        // DateTime dt=Calendar1.SelectedDate;
        // Response.Write(dt.ToString());
        //if (e.Day.Date == dt)
        //{
        //ComboBox a1 = new ComboBox();

        //a1.ID = 'a' + i.ToString();
        //a1.AutoCompleteMode = ComboBoxAutoCompleteMode.Suggest;
        //a1.DropDownStyle = ComboBoxStyle.DropDownList;
        //i++;
        //        e.Cell.Controls.Add(tb);
        //    }
        //Response.Write(e.Day.Date.ToString());
        DateTime dt = Calendar1.SelectedDate;
        if (e.Day.Date == dt)
        {
            ArrayList al=new ArrayList();
            al.Add(1);
            al.Add(2);
            al.Add(3);
            ComboBox cb = new ComboBox();
            cb.DataSource = al;
            cb.ID = "a";
            cb.AutoCompleteMode = ComboBoxAutoCompleteMode.Suggest;
            cb.DropDownStyle = ComboBoxStyle.DropDownList;
            e.Cell.Controls.Add(cb);
        }
    }
开发者ID:fping1245,项目名称:test20121224,代码行数:30,代码来源:arrcls.aspx.cs

示例5: Create

    public override Widget Create(object caller)
    {
        HBox box = new HBox();

        PropertiesView propview = (PropertiesView)caller;

        // Add the names of the sectors to a list
        List<String> sectorNames = new List<String>(propview.application.CurrentLevel.Sectors.Count);
        foreach(Sector sector in propview.application.CurrentLevel.Sectors) {
            sectorNames.Add(sector.Name);
        }

        // Populate a combo box with the sector names
        comboBox = new ComboBox(sectorNames.ToArray());

        // Get the index of the current value from the original list
        // due to limitations in ComboBox
        string val = (string)field.GetValue(Object);
        if (val != null)
            comboBox.Active = sectorNames.IndexOf(val);

        comboBox.Changed += OnComboBoxChanged;
        box.PackStart(comboBox, true, true, 0);

        box.Name = field.Name;

        CreateToolTip(caller, comboBox);

        return box;
    }
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:30,代码来源:ChooseSectorWidget.cs

示例6: Start

    private void Start()
    {
        //This is the list that we want to show up in our combobox options
        comboBoxList = new GUIContent[12];
        comboBoxList[0] = new GUIContent("First Level Test 1");
        comboBoxList[1] = new GUIContent("First Level Test 2");
        comboBoxList[2] = new GUIContent("First Level Test 3");
        comboBoxList[3] = new GUIContent("Second Level Test 1");
        comboBoxList[4] = new GUIContent("Second Level Test 2");
        comboBoxList[5] = new GUIContent("Second Level Test 3");
        comboBoxList[6] = new GUIContent("Third Level Test 1");
        comboBoxList[7] = new GUIContent("Third Level Test 2");
        comboBoxList[8] = new GUIContent("Third Level Test 3");
        comboBoxList[9] = new GUIContent("Fourth Level Test 1");
        comboBoxList[10] = new GUIContent("Fourth Level Test 2");
        comboBoxList[11] = new GUIContent("Fourth Level Test 3");

        listStyle.normal.textColor = Color.white;
        listStyle.onHover.background =
        listStyle.hover.background = new Texture2D(2, 2);
        listStyle.padding.left =
        listStyle.padding.right =
        listStyle.padding.top =
        listStyle.padding.bottom = 4;

        comboBoxControl = new ComboBox(new Rect(Screen.width/2 -130, Screen.height/2 - 25, 150, 20), comboBoxList[0], comboBoxList, "button", "box", listStyle);
    }
开发者ID:relinko01,项目名称:Dressage,代码行数:27,代码来源:TestSelection.cs

示例7: DataGridComboBoxColumn

 /// <summary>
 /// The only creator ;)
 /// </summary>
 /// <param name="colName">The name of the column</param>
 /// <param name="dataSource">The datasource that contains the lookup table</param>
 /// <param name="displayMember">The member of the lookuptable to display</param>
 /// <param name="valueMember">The member of the lookuptable with the value</param>
 /// <param name="dataGrid">The datagrid parent of this column</param>
 public DataGridComboBoxColumn(string colName, DataTable dataSource, string displayMember, string valueMember, DataGrid dataGrid)
 {
     _comboBox = new ComboBox();
     _comboBox.Visible = false;
     _comboBox.DataSource = dataSource;
     _dataTable = dataSource;
     _comboBox.DisplayMember = displayMember;
     _displayMember = displayMember;
     _valueMember = valueMember;
     _comboBox.ValueMember = valueMember;
     _comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
     Graphics _graphicsContext = dataGrid.CreateGraphics();
     float _widest = 0;
     SizeF _stringSize = new SizeF(0, 0);
     foreach (DataRow dr in dataSource.Rows)
     {
         _stringSize = _graphicsContext.MeasureString(dr[displayMember].ToString(), dataGrid.Font);
         if (_stringSize.Width > _widest)
         {
             _widest = _stringSize.Width;
         }
     }
     _comboBox.DropDownWidth = (int)Math.Ceiling(_widest);
     this.Width = _comboBox.DropDownWidth + 25; // Add the space for the dropdown arrow
     this.MappingName = colName;
     this.HeaderText = colName;
     dataGrid.Controls.Add(_comboBox);
 }
开发者ID:hayrettinbebek,项目名称:e-cafe,代码行数:36,代码来源:CellStyles.cs

示例8: Start

    void Start()
    {
        // Set up our fullscreen toggle button
        if (GameObject.Find("FullscreenToggle") != null) {
            fullscreen = GameObject.Find("FullscreenToggle").GetComponent<Toggle>();
            if (Screen.fullScreen) fullscreen.isOn = true;
            else fullscreen.isOn = false;
        }

        // Set up our resolution dropdown box
        if (GameObject.Find("ResolutionList") != null) {
            resolutions = GameObject.Find("ResolutionList").GetComponent<ComboBox>();
            ComboBoxItem[] items = new ComboBoxItem[Screen.resolutions.Length];
            int counter = 0;

            Resolution[] res = Screen.resolutions;
            foreach (Resolution r in res) {
                items[counter] = new ComboBoxItem(r);
                counter++;
            }

            resolutions.Items = items;
            resolutions.ItemsToDisplay = 5;

            Resolution tmpRes = Screen.currentResolution;
            foreach (Resolution r in Screen.resolutions) {
                if (Screen.width == r.width && Screen.height == r.height) {
                    tmpRes = r;
                    break;
                }
            }
            resolutions.SelectedIndex = System.Array.IndexOf(Screen.resolutions, tmpRes);
        }
    }
开发者ID:parkersprouse,项目名称:Spectrum,代码行数:34,代码来源:OptionsMenuHandler.cs

示例9: GUI_Proof

	// Constructor. It builds our application. It also calls its parent constructor through the base() keyword. 
	public GUI_Proof() : base("Example GTK# App"){
		// Sets a default size for our window. 
		this.SetDefaultSize(700, 500);
		// Centers the window on the screen. 
		this.SetPosition(WindowPosition.Center);
		// Sets an icon from the current directory
		//SetIconFromFile("web.png");
		// WIDGETS------------------------------------------
		// Containers
		Fixed fix = new Fixed();
		// Labels
		result.Text = "Pick a datatype";
		// ComboBox
		ComboBox cb = new ComboBox(dataTypes);
		// WIDGET's SETTINGS--------------------------------
		fix.Put(cb, 50, 30);
		fix.Put(result, 200, 30);
		// ADDS---------------------------------------------
		fix.Add(cb);
		fix.Add(result);
		this.Add(fix);
		// EVENT's ATTACH
		/* We plug a delegate to the DeleteEvent. This event is triggered, 
		 * when we click on the close button in the titlebar. Or press Alt+F4.
		 * Our delegate quits the application for good.  */
		//DeleteEvent += delegate { Application.Quit(); };
		/* This is another way, how we can plug an event handler to an event.
		 * It is just a bit more verbose. */
		this.DeleteEvent += new DeleteEventHandler(OnDelete);
		cb.Changed += OnChanged;
		// Now we show the window. The window is not visible, until we call the Show() method. 
		//Show();
		// This will work for all widgets and panels in the application
		this.ShowAll();
	}
开发者ID:JCarlosGMarias,项目名称:CSWarlords,代码行数:36,代码来源:GUI_Proof.cs

示例10: ComboBoxEditorBase

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="label"></param>
        /// <param name="property"></param>
        public ComboBoxEditorBase(PropertyLabel label, PropertyItem property)
            : base(property)
        {
            currentValue = property.Value;
              property.PropertyChanged += property_PropertyChanged;
              property.ValueError += property_ValueError;

              cbo = new ComboBox
              {
            Visibility = Visibility.Collapsed,
            Margin = new Thickness(0),
            VerticalAlignment = VerticalAlignment.Center,
            HorizontalAlignment = HorizontalAlignment.Stretch
              };

              cbo.DropDownOpened += cbo_DropDownOpened;
              cbo.LostFocus += cbo_LostFocus;

              this.InitializeCombo();

              pnl = new StackPanel();
              pnl.Children.Add(cbo);

              this.ShowTextBox();

              this.Content = pnl;
        }
开发者ID:DenisVuyka,项目名称:SPG,代码行数:32,代码来源:ComboBoxEditorBase.cs

示例11: AddThemeListTo

 /// <summary>
 /// Adds the list of themes to the specified combobox reference.
 /// </summary>
 /// <param name="comboBox"></param>
 public static void AddThemeListTo(ref ComboBox comboBox)
 {
     foreach (var theme in ThemeList)
     {
         comboBox.AddItem(theme.ToString(), ((int)theme).ToString());
     }
 }
开发者ID:omazlov,项目名称:Ext.NET.Examples,代码行数:11,代码来源:ThemeListHandler.cs

示例12: Form1

    public Form1()
    {
        this.Width = 335;
        this.Height = 380;
        this.Text = "ConvertDB";

        txtFileName = new TextBox {
          Location = new Point(10, 10),
          Size = new Size(270, 30),
          Text = "Please Input a target file name",
        };

        btnMDBFile = new Button {
          Location = new Point(280, 10),
          Size = new Size(30, 20),
          Text = "...",
        };

        clTables = new CheckedListBox  {
          Location = new Point(10, 30),
          Size = new Size(300, 200),
          Text = "...",
        };

        btnDBList = new Button {
          Location = new Point(10, 230),
          Size = new Size(30, 20),
          Text = "ls",
        };

        txtPostgreSQL = new TextBox {
          Location = new Point(40, 230),
          Size = new Size(270, 30),
          Text = "Server=192.168.33.20;Port=5432;User Id=postgres;Password=vagrant;database=template1;",
        };

        cboDatabaseList = new ComboBox {
          Location = new Point(10, 250),
          Size = new Size(300, 30),
          Text = "",
        };

        btnConvert = new Button {
          Location = new Point(10, 270),
          Size = new Size(300, 50),
          Text = "execute",
        };

        this.Controls.Add(txtFileName);
        this.Controls.Add(btnMDBFile);
        this.Controls.Add(clTables);
        this.Controls.Add(txtPostgreSQL);
        this.Controls.Add(btnDBList);
        this.Controls.Add(cboDatabaseList);
        this.Controls.Add(btnConvert);
        this.Load += new EventHandler(Form1_Load);
        btnMDBFile.Click += new EventHandler(btnMDBFile_Click);
        btnDBList.Click += new EventHandler(btnDBList_Click);
        btnConvert.Click += new EventHandler(btnConvert_Click);
    }
开发者ID:norick1701,项目名称:ConvertPGSQLFromMDB,代码行数:60,代码来源:ConvertDB.cs

示例13: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        ComboBox1 = new ComboBox();
        ComboBox1.ID = "ComboBox1";
        ComboBox1.Width = Unit.Pixel(200);
        ComboBox1.DataSourceID = "sds1";
        ComboBox1.DataTextField = "CompanyName";
        ComboBox1.DataValueField = "CustomerID";

        ComboBox1Container.Controls.Add(ComboBox1);

        ComboBox2 = new ComboBox();
        ComboBox2.ID = "ComboBox2";
        ComboBox2.Width = Unit.Pixel(200);
        ComboBox2.DataSourceID = "sds1";
        ComboBox2.DataTextField = "CompanyName";
        ComboBox2.DataValueField = "CustomerID";
        ComboBox2.CssSettings.ItemsContainer = "ob_iCboIC center";

        ComboBox2Container.Controls.Add(ComboBox2);

        ComboBox3 = new ComboBox();
        ComboBox3.ID = "ComboBox3";
        ComboBox3.Width = Unit.Pixel(200);
        ComboBox3.DataSourceID = "sds1";
        ComboBox3.DataTextField = "CompanyName";
        ComboBox3.DataValueField = "CustomerID";
        ComboBox3.CssSettings.ItemsContainer = "ob_iCboIC right";

        ComboBox3Container.Controls.Add(ComboBox3);  
    }
开发者ID:veraveramanolo,项目名称:power-show,代码行数:31,代码来源:cs_customization_align.aspx.cs

示例14: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        ComboBox1 = new ComboBox();
        ComboBox1.ID = "ComboBox1";
        ComboBox1.Width = Unit.Pixel(250);
        ComboBox1.Height = Unit.Pixel(200);
        ComboBox1.DataTextField = "CountryName";
        ComboBox1.DataValueField = "CountryID";
        ComboBox1.AutoClose = false;
        ComboBox1.AllowCustomText = true;
        ComboBox1.AutoValidate = true;
        ComboBox1.AllowEdit = false;
        ComboBox1.OpenOnFocus = true;
        ComboBox1.EmptyText = "Select countries ...";
        ComboBox1.EnableVirtualScrolling = true;
        ComboBox1.EnableLoadOnDemand = true;
        ComboBox1.LoadingItems += ComboBox1_LoadingItems;
        ComboBox1.ClientSideEvents.OnItemClick = "ComboBox1_ItemClick";
        ComboBox1.SelectionMode = ListSelectionMode.Multiple;

        ComboBox1.ItemTemplate = new ItemTemplate();
        ComboBox1.FooterTemplate = new FooterTemplate();

        ComboBox1Container.Controls.Add(ComboBox1);
       
    }
开发者ID:veraveramanolo,项目名称:power-show,代码行数:26,代码来源:cs_integration_checkboxes_ondemand.aspx.cs

示例15: MainForm

	public MainForm ()
	{
		// 
		// _comboBox
		// 
		_comboBox = new ComboBox ();
		_comboBox.Enabled = false;
		_comboBox.Location = new Point (8, 8);
		_comboBox.Width = 200;
		Controls.Add (_comboBox);
		// 
		// _selectButton
		// 
		_selectButton = new Button ();
		_selectButton.Location = new Point (230, 8);
		_selectButton.Size = new Size (60, 20);
		_selectButton.Text = "Select";
		_selectButton.Click += new EventHandler (SelectButton_Click);
		Controls.Add (_selectButton);
		// 
		// MainForm
		// 
		ClientSize = new Size (300, 50);
		Location = new Point (250, 100);
		StartPosition = FormStartPosition.Manual;
		Text = "bug #371751";
		Load += new EventHandler (MainForm_Load);
	}
开发者ID:mono,项目名称:gert,代码行数:28,代码来源:MainForm.cs


注:本文中的ComboBox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。