本文整理汇总了C#中System.Windows.Forms.ListBox类的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Forms.ListBox类的具体用法?C# System.Windows.Forms.ListBox怎么用?C# System.Windows.Forms.ListBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Windows.Forms.ListBox类属于命名空间,在下文中一共展示了System.Windows.Forms.ListBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeComponent
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.lbLog = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// lbLog
//
this.lbLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbLog.FormattingEnabled = true;
this.lbLog.Location = new System.Drawing.Point(0, 0);
this.lbLog.Name = "lbLog";
this.lbLog.Size = new System.Drawing.Size(361, 409);
this.lbLog.TabIndex = 1;
//
// dfmReport
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(361, 409);
this.Controls.Add(this.lbLog);
this.Name = "dfmReport";
this.Text = "log";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DfmReportFormClosing);
this.Load += new System.EventHandler(this.DfmReportLoad);
this.ResumeLayout(false);
}
示例2: EditValue
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
List<string> lstToSel = this.GetListToSelect(context);
IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (service != null)
{
System.Windows.Forms.ListBox lst = new System.Windows.Forms.ListBox();
lst.Click += delegate(object sender, EventArgs e)
{
service.CloseDropDown();
};
// 选中原有值
int iPos = -1;
foreach (string s in lstToSel)
{
int i = lst.Items.Add(s);
if (s.Equals(value)) iPos = i;
}
if (iPos != -1) lst.SelectedIndex = iPos;
// 下拉
service.DropDownControl(lst);
if (lst.SelectedItem != null)
value = lst.SelectedItem.ToString();
else
value = "";
}
return value;
}
示例3: InitializeComponent
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 12;
this.listBox1.Location = new System.Drawing.Point(0, 3);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(282, 88);
this.listBox1.TabIndex = 0;
//
// Frm_Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 93);
this.Controls.Add(this.listBox1);
this.Name = "Frm_Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "C#中实现文件拖放";
this.Load += new System.EventHandler(this.Form1_Load);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter);
this.ResumeLayout(false);
}
示例4: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnDelete = new System.Windows.Forms.Button();
this.btnEdit = new System.Windows.Forms.Button();
this.btnAdd = new System.Windows.Forms.Button();
this.lbDetails = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// btnDelete
//
this.btnDelete.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.btnDelete.Location = new System.Drawing.Point(374, 346);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(91, 23);
this.btnDelete.TabIndex = 10;
this.btnDelete.Text = "Delete";
this.btnDelete.UseVisualStyleBackColor = true;
//
// btnEdit
//
this.btnEdit.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.btnEdit.Location = new System.Drawing.Point(277, 346);
this.btnEdit.Name = "btnEdit";
this.btnEdit.Size = new System.Drawing.Size(91, 23);
this.btnEdit.TabIndex = 9;
this.btnEdit.Text = "Edit";
this.btnEdit.UseVisualStyleBackColor = true;
//
// btnAdd
//
this.btnAdd.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.btnAdd.Location = new System.Drawing.Point(180, 346);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(91, 23);
this.btnAdd.TabIndex = 8;
this.btnAdd.Text = "Add";
this.btnAdd.UseVisualStyleBackColor = true;
//
// lbDetails
//
this.lbDetails.FormattingEnabled = true;
this.lbDetails.Location = new System.Drawing.Point(12, 18);
this.lbDetails.Name = "lbDetails";
this.lbDetails.Size = new System.Drawing.Size(624, 316);
this.lbDetails.TabIndex = 7;
//
// FormDetails
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(648, 372);
this.Controls.Add(this.btnDelete);
this.Controls.Add(this.btnEdit);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.lbDetails);
this.MinimizeBox = false;
this.Name = "FormDetails";
this.Text = "FormDetails";
this.ResumeLayout(false);
}
示例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.lstProducts = new System.Windows.Forms.ListBox();
this.btnExit = new System.Windows.Forms.Button();
this.btnDelete = new System.Windows.Forms.Button();
this.btnAdd = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lstProducts
//
this.lstProducts.FormattingEnabled = true;
this.lstProducts.Location = new System.Drawing.Point(12, 12);
this.lstProducts.Name = "lstProducts";
this.lstProducts.Size = new System.Drawing.Size(352, 160);
this.lstProducts.TabIndex = 10;
//
// btnExit
//
this.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnExit.Location = new System.Drawing.Point(380, 76);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(104, 24);
this.btnExit.TabIndex = 9;
this.btnExit.Text = "E&xit";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// btnDelete
//
this.btnDelete.Location = new System.Drawing.Point(380, 44);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(104, 24);
this.btnDelete.TabIndex = 8;
this.btnDelete.Text = "Delete Product...";
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
//
// btnAdd
//
this.btnAdd.Location = new System.Drawing.Point(380, 12);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(104, 24);
this.btnAdd.TabIndex = 7;
this.btnAdd.Text = "Add Product...";
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// frmProductMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnExit;
this.ClientSize = new System.Drawing.Size(502, 181);
this.Controls.Add(this.lstProducts);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnDelete);
this.Controls.Add(this.btnAdd);
this.Name = "frmProductMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Product Maintenance";
this.Load += new System.EventHandler(this.frmProductMain_Load);
this.ResumeLayout(false);
}
示例6: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.Items.AddRange(new object[] {
"Bệnh viện 30/4",
"Bệnh viện 115",
"Bệnh viện Thống Nhất"});
this.listBox1.Location = new System.Drawing.Point(22, 44);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(352, 173);
this.listBox1.TabIndex = 0;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(400, 262);
this.Controls.Add(this.listBox1);
this.Name = "Form1";
this.Text = "Đặt lịch khám";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
示例7: EditValue
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
Reference retval = null;
try
{
edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));
var table = (Table)context.Instance;
var root = (ModelRoot)table.Root;
var referenceCollection = table.Columns;
//Create the list box
var newBox = new System.Windows.Forms.ListBox();
newBox.Click += new EventHandler(newBox_Click);
newBox.IntegralHeight = false;
newBox.Items.Add("(Not Set)");
foreach(Reference reference in referenceCollection)
{
var column = ((ModelRoot)reference.Root).Database.Columns.GetById(reference.Ref)[0];
newBox.Items.Add(column);
}
edSvc.DropDownControl(newBox);
if((newBox.SelectedIndex > 0) && (newBox.SelectedItem != null))
retval = ((Column)newBox.SelectedItem).CreateRef();
}
catch(Exception ex) { }
return retval;
}
示例8: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.lbContacts = new System.Windows.Forms.ListBox();
this.label1 = new System.Windows.Forms.Label();
this.btnStartChat = new System.Windows.Forms.Button();
this.chatCheckTimer = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// lbContacts
//
this.lbContacts.FormattingEnabled = true;
this.lbContacts.Location = new System.Drawing.Point(12, 25);
this.lbContacts.Name = "lbContacts";
this.lbContacts.Size = new System.Drawing.Size(207, 290);
this.lbContacts.TabIndex = 0;
this.lbContacts.SelectedIndexChanged += new System.EventHandler(this.lbContacts_SelectedIndexChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(49, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Contacts";
//
// btnStartChat
//
this.btnStartChat.Location = new System.Drawing.Point(225, 25);
this.btnStartChat.Name = "btnStartChat";
this.btnStartChat.Size = new System.Drawing.Size(106, 23);
this.btnStartChat.TabIndex = 2;
this.btnStartChat.Text = "Start Chat";
this.btnStartChat.UseVisualStyleBackColor = true;
this.btnStartChat.Click += new System.EventHandler(this.btnStartChat_Click);
//
// chatCheckTimer
//
this.chatCheckTimer.Enabled = true;
this.chatCheckTimer.Interval = 2000;
this.chatCheckTimer.Tick += new System.EventHandler(this.chatCheckTimer_Tick);
//
// HoofdForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(340, 327);
this.Controls.Add(this.btnStartChat);
this.Controls.Add(this.label1);
this.Controls.Add(this.lbContacts);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "HoofdForm";
this.Text = "HoofdForm";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HoofdForm_FormClosing);
this.ResumeLayout(false);
this.PerformLayout();
}
示例9: EditValue
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
var retval = System.Data.SqlDbType.VarChar;
try
{
edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));
var column = (ColumnBase)context.Instance;
retval = column.DataType;
//Create the list box
var newBox = new System.Windows.Forms.ListBox();
newBox.Click += new EventHandler(newBox_Click);
newBox.IntegralHeight = false;
var values = new List<string>();
foreach (var t in Enum.GetNames(typeof(System.Data.SqlDbType)).OrderBy(x => x))
{
values.Add(t);
}
newBox.Items.AddRange(values.ToArray());
newBox.SelectedIndex = newBox.FindString(column.DataType.ToString());
edSvc.DropDownControl(newBox);
if ((column != null) && (newBox.SelectedIndex != -1))
retval = (System.Data.SqlDbType)Enum.Parse(typeof(System.Data.SqlDbType), values[newBox.SelectedIndex]);
}
catch (Exception ex) { }
return retval;
}
示例10: EditValue
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
var retval = false;
try
{
edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));
var column = (ColumnBase)context.Instance;
retval = column.AllowNull;
//Create the list box
var newBox = new System.Windows.Forms.ListBox();
newBox.Click += new EventHandler(newBox_Click);
newBox.IntegralHeight = false;
var values = new List<string>();
values.Add(false.ToString());
values.Add(true.ToString());
newBox.Items.AddRange(values.ToArray());
newBox.SelectedIndex = (column.AllowNull ? 1 : 0);
edSvc.DropDownControl(newBox);
if ((column != null) && (newBox.SelectedIndex != -1))
retval = (newBox.SelectedIndex == 0 ? false : true);
}
catch (Exception ex) { }
return retval;
}
示例11: EditValue
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
var retval = Guid.Empty;
try
{
edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));
var moduleRule = context.Instance as ModuleRule;
var modulelist = moduleRule.Module.nHydrateModel.Modules.OrderBy(x => x.Name).Where(x => x.Id != moduleRule.Module.Id).ToList();
var selected = modulelist.FirstOrDefault(x=>x.Id == moduleRule.DependentModule);
//Create the list box
var newBox = new System.Windows.Forms.ListBox();
newBox.Click += new EventHandler(newBox_Click);
newBox.IntegralHeight = false;
var values = new List<string>();
values.Add(false.ToString());
values.Add(true.ToString());
newBox.Items.AddRange(modulelist.Select(x => x.Name).ToArray());
if (selected != null)
newBox.SelectedIndex = modulelist.IndexOf(selected);
edSvc.DropDownControl(newBox);
if ((moduleRule != null) && (newBox.SelectedIndex != -1))
retval = modulelist[newBox.SelectedIndex].Id;
}
catch (Exception ex) { }
return retval;
}
示例12: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 14;
this.listBox1.Location = new System.Drawing.Point(0, 0);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(216, 158);
this.listBox1.TabIndex = 0;
//
// StackFrameView
//
this.ClientSize = new System.Drawing.Size(219, 161);
this.CloseButton = false;
this.CloseButtonVisible = false;
this.Controls.Add(this.listBox1);
this.HideOnClose = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(235, 200);
this.Name = "StackFrameView";
this.Padding = new System.Windows.Forms.Padding(0, 2, 0, 2);
this.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.DockLeft;
this.TabText = "Stack Frame";
this.Text = "Stack Frame";
this.ResumeLayout(false);
}
示例13: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 16;
this.listBox1.Location = new System.Drawing.Point(1, 0);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(284, 256);
this.listBox1.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(282, 253);
this.Controls.Add(this.listBox1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1";
this.Opacity = 0.01D;
this.ShowInTaskbar = false;
this.Text = "VitratF";
this.ResumeLayout(false);
}
示例14: EditValue
/// <summary>
/// Overrides the method used to provide basic behaviour for selecting editor.
/// Shows our custom control for editing the value.
/// </summary>
/// <param name="context">The context of the editing control</param>
/// <param name="provider">A valid service provider</param>
/// <param name="value">The current value of the object to edit</param>
/// <returns>The new value of the object</returns>
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (context == null || context.Instance == null || provider == null)
{
return base.EditValue(context, provider, value);
}
if ((m_EdSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService))) == null)
{
return value;
}
// Create a CheckedListBox and populate it with all the propertylist values
m_List = new System.Windows.Forms.ListBox();
m_List.BorderStyle = System.Windows.Forms.BorderStyle.None;
foreach (GXCategory cat in (context.Instance as GXKeepalive).Parent.Categories)
{
foreach (GXProperty prop in cat.Properties)
{
m_List.Items.Add(prop);
}
}
if (value != null)
{
m_List.SelectedIndex = m_List.Items.IndexOf(value);
}
m_List.SelectedIndexChanged += new System.EventHandler(this.OnSelectedIndexChanged);
// Show Listbox as a DropDownControl. This methods returns only when the dropdowncontrol is closed
m_EdSvc.DropDownControl(m_List);
(context.Instance as GXKeepalive).Target = m_List.SelectedItem;
return value;
}
示例15: HandlePluginLaunch
private void HandlePluginLaunch(object sender, EventArgs e)
{
//NWN2Toolset.NWN2.Data.Blueprints.NWN2GlobalBlueprintManager bpManager = new NWN2Toolset.NWN2.Data.Blueprints.NWN2GlobalBlueprintManager();
//bpManager.Initialize();
NWN2Toolset.NWN2.Data.TypedCollections.NWN2BlueprintCollection items = NWN2Toolset.NWN2.Data.Blueprints.NWN2GlobalBlueprintManager.GetBlueprintsOfType(NWN2Toolset.NWN2.Data.Templates.NWN2ObjectType.Item);
ALFAItemBlueprint scroll;
System.Windows.Forms.Form form = new System.Windows.Forms.Form();
/*System.Windows.Forms.TextBox text = new System.Windows.Forms.TextBox();
text.Size = new System.Drawing.Size(400, 300);
text.Multiline = true;
text.WordWrap = false;
text.AcceptsReturn = true;
text.AcceptsTab = true;
text.ScrollBars = System.Windows.Forms.ScrollBars.Both;
text.Text = scroll.ToString();*/
System.Windows.Forms.ListBox listBox = new System.Windows.Forms.ListBox();
listBox.Sorted = true;
listBox.HorizontalScrollbar = true;
listBox.Size = new System.Drawing.Size(400, 300);
form.Controls.Add(listBox);
form.Size = new System.Drawing.Size(430, 330);
form.Show();
//items.Add(scroll.ItemBlueprint);
//scroll.TemplateResRef = "TEST RESREF";
//scroll.AddItemProperty(ALFAItemProperty.CastSpell1ChargeItemProperty(0));
//scroll.AddItemProperty(ALFAItemProperty.WizardOnlyItemProperty());
//items.Add(scroll.ItemBlueprint);
ConsumableCreator cc = new ConsumableCreator();
cc.Run();
}