本文整理汇总了C#中System.Windows.Forms.ComboBox类的典型用法代码示例。如果您正苦于以下问题:C# ComboBox类的具体用法?C# ComboBox怎么用?C# ComboBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComboBox类属于System.Windows.Forms命名空间,在下文中一共展示了ComboBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CardInfoBindComboBox
/// <summary>
/// 绑定标识卡号信息
/// </summary>
/// <param name="cmb"></param>
/// <param name="deptID"></param>
public void CardInfoBindComboBox(ComboBox cmb,string deptID)
{
DataSet ds = null;
try
{
ds = HMDAL.GetEmpInfo(deptID);
if (ds != null && ds.Tables.Count > 0)
{
DataTable dt = ds.Tables[0];
DataRow dr = dt.NewRow();
dr["CodeSenderAddress"] = "所有";
dr["empName"] = "0";
dt.Rows.InsertAt(dr, 0);
dt.AcceptChanges();
cmb.DataSource = dt;
cmb.DisplayMember = "CodeSenderAddress";
cmb.ValueMember = "empName";
}
else
{
cmb.Items.Add("所有");
}
}
catch
{
cmb.Items.Add("所有");
}
}
示例2: InsertPInvokeSignaturesForm
public InsertPInvokeSignaturesForm()
{
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("PInvokeAddIn.Resources.InsertPInvokeSignaturesForm.xfrm"));
signatureRichTextBox = ((RichTextBox)ControlDictionary["SignatureRichTextBox"]);
// Hook up events.
closeButton = ((Button)ControlDictionary["CloseButton"]);
closeButton.Click += new EventHandler(CloseButtonClick);
insertButton = ((Button)ControlDictionary["InsertButton"]);
insertButton.Enabled = false;
insertButton.Click += new EventHandler(InsertButtonClick);
findButton = ((Button)ControlDictionary["FindButton"]);
findButton.Click += new EventHandler(FindButtonClick);
functionNameComboBox = ((ComboBox)ControlDictionary["FunctionNameComboBox"]);
functionNameComboBox.AutoCompleteMode = AutoCompleteMode.Suggest;
functionNameComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
moduleNameComboBox = ((ComboBox)ControlDictionary["ModuleNameComboBox"]);
moduleNameComboBox.AutoCompleteMode = AutoCompleteMode.Suggest;
moduleNameComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
moreInfoLinkLabel = ((LinkLabel)ControlDictionary["MoreInfoLinkLabel"]);
moreInfoLinkLabel.LinkClicked += new LinkLabelLinkClickedEventHandler(MoreInfoLinkClicked);
languageComboBox = ((ComboBox)ControlDictionary["LanguageComboBox"]);
languageComboBox.SelectedIndexChanged += new EventHandler(LanguageComboBoxSelectedIndexChanged);
SetupLanguages();
SetupFunctionNames();
SetupModuleNames();
}
示例3: GetAppointmentIDsAndTests
private void GetAppointmentIDsAndTests()
{
this.Clear();
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
cmb.HeaderText = "Select Test";
ComboBox cbTests = new ComboBox();
foreach (LabTest test in testList)
{
cmb.Items.Add(test.TestType);
}
dgvAddTest.Columns.Add(cmb);
//cbAppointmentID.SelectedIndexChanged -= cbAppointmentID_SelectedIndexChanged;
//cbAppointmentID.DataSource = null;
//cbAppointmentID.Items.Clear();
//cbAppointmentID.SelectedIndexChanged += cbAppointmentID_SelectedIndexChanged;
//appointmentsList = AppointmentController.GetAppointmentsWithoutDiagnosis();
//cbAppointmentID.DataSource = appointmentsList;
//cbAppointmentID.DisplayMember = "AppointmentID";
//cbAppointmentID.ValueMember = "AppointmentID";
//cbTest.SelectedIndexChanged -= cbTest_SelectedIndexChanged;
//cbTest.DataSource = null;
//cbTest.Items.Clear();
//cbTest.SelectedIndexChanged += cbTest_SelectedIndexChanged;
//testList = LabTestController.GetAllLabTests();
//cbTest.DataSource = testList;
//cbTest.DisplayMember = "TestType";
//cbTest.ValueMember = "TestId";
}
示例4: InitDropdownTypes
public static void InitDropdownTypes(ComboBox cbo, ModuleDefinition module)
{
using (new SimpleWaitCursor())
{
object savedItem = cbo.SelectedItem;
cbo.Items.Clear();
cbo.Sorted = true;
if (module != null)
{
foreach (TypeDefinition td in module.AllTypes)
{
if (td.FullName.StartsWith("<")) continue;
cbo.Items.Add(td);
}
}
Type[] systemTypes = typeof(System.Int32).Module.GetTypes();
foreach (Type systemType in systemTypes)
{
if (systemType.FullName.StartsWith("<")) continue;
cbo.Items.Add(systemType);
}
if (savedItem != null)
{
if (!cbo.Items.Contains(savedItem))
{
cbo.Items.Add(savedItem);
}
cbo.SelectedItem = savedItem;
}
}
}
示例5: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cboSourceLayer = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// cboSourceLayer
//
this.cboSourceLayer.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboSourceLayer.DropDownWidth = 260;
this.cboSourceLayer.Items.AddRange(new object[] {
"<Business Features Source Layer>"});
this.cboSourceLayer.Location = new System.Drawing.Point(16, 24);
this.cboSourceLayer.Name = "cboSourceLayer";
this.cboSourceLayer.Size = new System.Drawing.Size(216, 21);
this.cboSourceLayer.TabIndex = 0;
//this.cboSourceLayer.SelectedIndexChanged += new System.EventHandler(this.cboSourceLayer_SelectedIndexChanged);
//
// SourceLayerContainerForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(312, 77);
this.Controls.Add(this.cboSourceLayer);
this.Name = "SourceLayerContainerForm";
this.Text = "This is just a control container form";
this.ResumeLayout(false);
}
示例6: GetWinFormsControlAdapter
private static IWinFormsComboBoxAdapter GetWinFormsControlAdapter()
{
var control = new ComboBox();
var winFormsControlAdapter = MockRepository.GenerateStub<IWinFormsComboBoxAdapter>();
winFormsControlAdapter.Stub(adapter => adapter.WrappedControl).Return(control);
return winFormsControlAdapter;
}
示例7: AbstractCreate
protected override void AbstractCreate(object value, ref int tabIndex)
{
var left = Margin;
var top = Margin;
// ラベルの作成 top+3 は後のテキストボックスとの整合のため
_label = (Label) Create(Panel, new Label(), left, top + 3, -1);
_label.Text = Help;
// label.setBorder(new LineBorder(Color.RED, 2, true)); //Debug 赤枠
left += LabelWidth(_label) + 10; // オフセット移動
// コンボボックスの配置
_comboBox = (ComboBox) Create(Panel, new ComboBox(), left, top, tabIndex++);
_comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
foreach (var s in _list){
_comboBox.Items.Add(s);
var w = TextWidth(s) + 20;
if (w > _comboBox.Width){
_comboBox.Width = w;
}
}
//comboBox.addActionListener(this);
_comboBox.SelectedIndexChanged += Change;//[C#] コントロールの変化をイベント処理する
//comboBox.setSize(width, comboBox.getHeight());
_comboBox.Width = _width;
left += _comboBox.Width; // オフセット移動
//値の設定
AbstractWrite(value);
// パネルのサイズ設定
Panel.Size = new Size(left + Margin, DefaultHeight + Margin);
}
示例8: ContestantWrongInfo
public ContestantWrongInfo(List<ContestantListLine> notValidInfo, List<bool[]> notValidInfoColumn)
{
InitializeComponent();
this.notValidInfo = notValidInfo;
this.notValidInfoColumn = notValidInfoColumn;
nameColumn.AspectGetter = delegate(object x) { return ((ContestantListLine)x).FirstName; };
nameColumn.AspectPutter = delegate(object x, object newValue) { ((ContestantListLine)x).FirstName = newValue.ToString(); };
lastnameColumn.AspectGetter = delegate(object x) { return ((ContestantListLine)x).LastName; };
lastnameColumn.AspectPutter = delegate(object x, object newValue) { ((ContestantListLine)x).LastName = newValue.ToString(); };
seuraColumn.AspectGetter = delegate(object x) { return ((ContestantListLine)x).LastName; };
seuraColumn.AspectPutter = delegate(object x, object newValue) { ((ContestantListLine)x).LastName = newValue.ToString(); };
//COMPOBOX TEST
ComboBox comboBox1 = new ComboBox();
comboBox1.Name = "comboBox1";
comboBox1.BackColor = System.Drawing.Color.Orange;
comboBox1.Items.Add("Mahesh Chand");
comboBox1.Items.Add("Mike Gold");
objectListView1.SetObjects(notValidInfo);
}
示例9: olvCellEditStarting
private void olvCellEditStarting(object sender, CellEditEventArgs e)
{
Console.WriteLine("LKLJKLJKL");
List<String> countries = new List<String> {"testi", "joku", "Hiiri"};
ComboBox cboCombo = new ComboBox();
cboCombo.Bounds = e.CellBounds;
cboCombo.Left = e.CellBounds.Left + 1;
cboCombo.Width = e.CellBounds.Width - 1;
cboCombo.DropDownStyle = ComboBoxStyle.DropDownList;
cboCombo.DisplayMember = "Display";
cboCombo.ValueMember = "ID";
cboCombo.DataSource = countries;
cboCombo.AutoCompleteSource = AutoCompleteSource.ListItems;
cboCombo.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cboCombo.Update();
//int intComboEditorSelectedValue = countries.Find(item => item.Display == (string)(e.Value)).ID; e.Control = cboCombo; cboCombo.SelectedValue = intComboEditorSelectedValue; //fails silently
/*
if (e.Column.Text != "Seura")
return;
ComboBox cb = new ComboBox();
cb.Bounds = e.CellBounds;
cb.Font = ((ObjectListView)sender).Font;
cb.DropDownStyle = ComboBoxStyle.DropDownList;
cb.Items.AddRange(new String[] { "Pay to eat out", "Suggest take-away", "Passable", "Seek dinner invitation", "Hire as chef" });
cb.SelectedIndex = ((int)e.Value) / 10;
//cb.SelectedIndexChanged += new EventHandler(cb_SelectedIndexChanged);
cb.Tag = e.RowObject; // remember which person we are editing
e.Control = cb;
*
* */
}
示例10: CanExtend_ComboBox_False
public void CanExtend_ComboBox_False()
{
using (ComboBox comboBox = new ComboBox())
{
Assert.IsFalse(((IExtenderProvider) _prompt).CanExtend(comboBox));
}
}
示例11: TgcEnumModifier
public TgcEnumModifier(string varName, Type enumType, object defaultValue)
: base(varName)
{
this.enumType = enumType;
this.selectValue = defaultValue;
//Buscar indice del defaultValue dentro del enum
string[] enumNames = Enum.GetNames(enumType);
string currentName = Enum.GetName(enumType, defaultValue);
int selectedIndex = -1;
for (int i = 0; i < enumNames.Length; i++)
{
if (currentName.Equals(enumNames[i]))
{
selectedIndex = i;
break;
}
}
comboBox = new ComboBox();
comboBox.Margin = new Padding(0);
comboBox.Size = new System.Drawing.Size(100, 20);
comboBox.Items.AddRange(enumNames);
comboBox.SelectedIndex = selectedIndex;
comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox.SelectionChangeCommitted += new EventHandler(comboBox_SelectionChangeCommitted);
contentPanel.Controls.Add(comboBox);
}
示例12: AddNewComboBox
public ComboBox AddNewComboBox()
{
ComboBox newComboBox = new
ComboBox();
//add to the collection list
this.List.Add(newComboBox);
//add to the overall form controls
Hatchu.Controls.Add(newComboBox);
newComboBox.Top = 22 + levelCount * 170;
newComboBox.Width = 95;
newComboBox.Left = miniCount * (newComboBox.Width + 10) + 80;
newComboBox.Tag = this.Count;
newComboBox.Text = "";
newComboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
newComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
newComboBox.KeyDown += new System.Windows.Forms.KeyEventHandler(EnterHandler);
AddDanceTypes(newComboBox);
miniCount++;
if (Count % 6 == 0)
{
miniCount = 0;
levelCount++;
}
return newComboBox;
}
示例13: TextInputDialog
public TextInputDialog(string []query,object []initialItem, object []comboBoxItems)
{
InitializeComponent();
Control[] controls = new Control[query.Length];
for (int i = 0; i < query.Length; i++ )
{
if (comboBoxItems == null || comboBoxItems.Length <= i || comboBoxItems[i] == null)
{
controls[i] = new TextBox();
if (initialItem != null && initialItem[i] != null)
controls[i].Text = "" + initialItem[i];
if (i == query.Length - 1)
(controls[i] as TextBox).Multiline = true;
}
else
{
controls[i] = new ComboBox();
(controls[i] as ComboBox).DataSource = comboBoxItems.Clone();
if (initialItem != null && initialItem[i] != null)
(controls[i] as ComboBox).SelectedItem = initialItem[i];
}
}
AddAllControls(query, controls);
}
示例14: SetupComboBox
private void SetupComboBox(System.Type type, ComboBox comboBox)
{
Array types = Enum.GetValues(type);
for (int intI = 0; intI < types.Length; intI++)
comboBox.Items.Add(types.GetValue(intI));
comboBox.SelectedIndex = 0;
}
示例15: InitializeComponent
private void InitializeComponent()
{
this.comboBoxApplication = new System.Windows.Forms.ComboBox();
this.buttonOK = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// comboBoxApplication
//
this.comboBoxApplication.Location = new System.Drawing.Point(8, 8);
this.comboBoxApplication.Name = "comboBoxApplication";
this.comboBoxApplication.Size = new System.Drawing.Size(280, 21);
this.comboBoxApplication.TabIndex = 0;
//
// buttonOK
//
this.buttonOK.Location = new System.Drawing.Point(296, 8);
this.buttonOK.Name = "buttonOK";
this.buttonOK.TabIndex = 1;
this.buttonOK.Text = "OK";
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// FSelectApplication
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(376, 37);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.comboBoxApplication);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.Name = "FSelectApplication";
this.Text = "Select Application";
this.Text = Strings.SelectApplication;
this.Load += new System.EventHandler(this.FSelectApplication_Load);
this.ResumeLayout(false);
}