本文整理汇总了C#中System.Windows.Forms.ListBox类的典型用法代码示例。如果您正苦于以下问题:C# ListBox类的具体用法?C# ListBox怎么用?C# ListBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListBox类属于System.Windows.Forms命名空间,在下文中一共展示了ListBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Continent
public Continent(ListBox displayBox, Random rGen, int nAnimalTypes, Graphics canvas)
{
this.displayBox = displayBox;
this.rGen = rGen;
this.nAnimalTypes = nAnimalTypes;
this.canvas = canvas;
}
示例2: RefreshListBox
private static void RefreshListBox(ListBox log, string[] items)
{
var selectLastIndex = log.Items.Count == 0 || log.SelectedIndex == log.Items.Count - 1;
log.DataSource = items;
if (selectLastIndex && log.Items.Count > 0)
log.SelectedIndex = log.Items.Count - 1;
}
示例3: 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(AboutForm));
this.label1 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(64, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(248, 32);
this.label1.TabIndex = 1;
this.label1.Text = "HyperLoad 2.0";
//
// listBox1
//
this.listBox1.Items.AddRange(new object[] {
"This program is completely free to use!",
"",
"Hyperload is an open-source program that can be used to",
"program *.HEX files to your microcontroller.",
"",
"The Hyperload Protocol & related information can be found at:",
"www.sociaLLedge.com/sjsu"});
this.listBox1.Location = new System.Drawing.Point(14, 84);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(304, 108);
this.listBox1.TabIndex = 5;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.listBox1);
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(320, 210);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
//
// AboutForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(338, 225);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "AboutForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "About";
this.Deactivate += new System.EventHandler(this.AboutForm_Deactivate);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
示例4: SetUp
protected override void SetUp ()
{
listBox = new ListBox();
form = new Form();
form.ShowInTaskbar = false;
base.SetUp ();
}
示例5: PreferenceListDetails
public PreferenceListDetails(PreferenceList preferenceList, ListBox listBox, Button buttonUp, Button buttonDown)
{
_preferenceList = preferenceList;
_list = listBox;
_up = buttonUp;
_down = buttonDown;
}
示例6: InitTabControlPages
private void InitTabControlPages()
{
foreach(var obj in CardLevels)
{
var page = new TabPage { Text = CardLevel.RoleCardLevelName(obj) };
CardTabControl.TabPages.Add(page);
var listData = new BindingList<RoleCard>();
var list = new ListBox()
{
Dock = DockStyle.Fill,
ContextMenuStrip = TabControlContextMenu,
DisplayMember = "Name",
ValueMember = "Id",
DataSource = listData,
};
list.SelectedIndexChanged += (sender, msg) =>
{
var item = list.SelectedItem as RoleCard;
if (ListOfRoleCardList[CardTabControl.SelectedIndex].Contains(item))
{
SelectedItem = item;
cardInfoControl1.BeginModify();
cardInfoControl1.Images = CardImageDictionary[SelectedItem.Id];
cardInfoControl1.RoleCard = SelectedItem;
cardInfoControl1.EndModify();
}
};
page.Controls.Add(list);
ListOfRoleCardList.Add(listData);
}
}
示例7: SaveCurrentEnvironment
public static void SaveCurrentEnvironment(LoadedSettings loadedSettings, ListBox environmentsListBox, EnvironmentStruct environment)
{
var currentEnvironment = loadedSettings.Environments.First(env => env.ID == environment.ID);
if (environment.ID == Guid.Empty) return;
if (currentEnvironment.Name != environment.Name)
currentEnvironment.Name = environment.Name;
if (currentEnvironment.SubkeyValue != environment.SubkeyValue)
currentEnvironment.SubkeyValue = environment.SubkeyValue;
if (currentEnvironment.HotKey != environment.HotKey)
currentEnvironment.HotKey = environment.HotKey;
if (currentEnvironment.IconLabel != environment.IconLabel)
currentEnvironment.IconLabel = environment.IconLabel;
if (currentEnvironment.IconTextColor != environment.IconTextColor)
currentEnvironment.IconTextColor = environment.IconTextColor;
if (currentEnvironment.IconBackgroundColor != environment.IconBackgroundColor)
currentEnvironment.IconBackgroundColor = environment.IconBackgroundColor;
if (currentEnvironment.LoadIcon != environment.LoadIcon)
currentEnvironment.LoadIcon = environment.LoadIcon;
if (currentEnvironment.IconFileLocation != environment.IconFileLocation)
currentEnvironment.IconFileLocation = environment.IconFileLocation;
if (currentEnvironment.DisplayOnMenu != environment.DisplayOnMenu)
currentEnvironment.DisplayOnMenu = environment.DisplayOnMenu;
ListboxUtils.RepopulateListBox(true, environmentsListBox, loadedSettings, environment.ID);
ListboxUtils.SetCurrentOrderFromListBoxAndSave(true, environmentsListBox, loadedSettings);
MessageBox.Show($"{currentEnvironment.Name} {Constants.Messages.SavedSuccessfully}",
$"Environment {Constants.Messages.SavedSuccessfullyCaption}",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
示例8: add_list_content
public void add_list_content(ListBox listbox, ArrayList strings)
{
foreach (String name in strings)
{
listbox.Items.Add(name);
}
}
示例9: ShowResponse
public void ShowResponse(IRequest request, Uri response)
{
_guiContext.Post(_ =>
{
foreach (TabPage source in responsesTab.TabPages)
{
if (source.Text.Equals(request.SearchCriteria.Value))
{
ListBox list;
if (source.Controls.Count == 0)
{
list = new ListBox {Dock = DockStyle.Fill};
source.Controls.Add(list);
}
else
list = source.Controls[0] as ListBox;
if (list != null)
{
list.Items.Add(response);
}
break;
}
}
}, null);
}
示例10: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lbNodes = new System.Windows.Forms.ListBox();
this.btnLoadXml = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lbNodes
//
this.lbNodes.Location = new System.Drawing.Point(8, 40);
this.lbNodes.Name = "lbNodes";
this.lbNodes.Size = new System.Drawing.Size(432, 303);
this.lbNodes.TabIndex = 3;
//
// btnLoadXml
//
this.btnLoadXml.Location = new System.Drawing.Point(8, 8);
this.btnLoadXml.Name = "btnLoadXml";
this.btnLoadXml.Size = new System.Drawing.Size(112, 23);
this.btnLoadXml.TabIndex = 2;
this.btnLoadXml.Text = "Load XML";
this.btnLoadXml.Click += new System.EventHandler(this.btnLoadXml_Click);
//
// StepByStep6_28
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(448, 357);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lbNodes,
this.btnLoadXml});
this.Name = "StepByStep6_28";
this.Text = "StepByStep6_28";
this.ResumeLayout(false);
}
示例11: dealAndDisplay
//deals the deck to the players
public void dealAndDisplay(ListBox player1,ListBox player2,ListBox player3,ListBox player4)
{
hands = new Hand[numPlayers];
//initialises hand array get null exception error without it
for (int i = 0; i < numPlayers; i++)
{
hands[i] = new Hand();
}
int count=0;
for (int i = 0; i < handSize; i++)
{
for (int j = 0; j < numPlayers; j++)
{
hands[j].Cards[i] = deck[count];
count++;
}
}
hands[0].displayHand(player1);
hands[1].displayHand(player2);
hands[2].displayHand(player3);
hands[3].displayHand(player4);
}
示例12: AddNewListBox
public ListBox AddNewListBox()
{
ListBox newListBox = new
ListBox();
//add to the collection list
this.List.Add(newListBox);
//add to the overall form controls
Hatchu.Controls.Add(newListBox);
newListBox.Top = 69 + levelCount * 170;
newListBox.Width = 95;
newListBox.Left = miniCount * (newListBox.Width + 10) + 80;
newListBox.Tag = this.Count;
newListBox.Text = "";
miniCount++;
if (Count % 6 == 0)
{
miniCount = 0;
levelCount++;
}
newListBox.KeyDown += new System.Windows.Forms.KeyEventHandler(KeyDownHandler);
return newListBox;
}
示例13: EditValue
public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
{
if (context != null && provider != null)
{
edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (edSvc != null)
{
lb = new ListBox();
lb.Items.AddRange(new object[] {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"});
lb.SelectedIndexChanged += new System.EventHandler(lb_SelectedIndexChanged);
edSvc.DropDownControl(lb);
}
return text;
}
return base.EditValue(context, provider, value);
}
示例14: AutoCompleteTextbox
/// <summary>
/// Constructor
/// </summary>
public AutoCompleteTextbox()
: base()
{
entireList = new List<string>();
matchingList = new List<string>();
lboxSuggestions = new ListBox();
lboxSuggestions.Name = "SuggestionListBox";
lboxSuggestions.Font = this.Font;
lboxSuggestions.Visible = true;
lboxSuggestions.Dock = DockStyle.Fill;// make the listbox fill the panel
lboxSuggestions.SelectionMode = SelectionMode.One;
lboxSuggestions.KeyDown += new KeyEventHandler(listBox_KeyDown);
lboxSuggestions.MouseClick += new MouseEventHandler(listBox_MouseClick);
lboxSuggestions.DataSource = matchingList;// Bind matchingList as DataSource to the listbox
this.GotFocus += new EventHandler(AutoCompleteTextbox_GotFocus);
//Will hold listbox
panel = new Panel();
panel.Visible = false;
panel.Font = this.Font;
panel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
panel.ClientSize = new System.Drawing.Size(1, 1);
panel.Name = "SuggestionPanel";
panel.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0);
panel.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
panel.Text = "";
panel.PerformLayout();
if (!panel.Controls.Contains(lboxSuggestions)) { this.panel.Controls.Add(lboxSuggestions); }
}
示例15: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(32, 32);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(208, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Call \"HelloWorld\" on remote object";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// listBox1
//
this.listBox1.Location = new System.Drawing.Point(32, 72);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(224, 95);
this.listBox1.TabIndex = 1;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.listBox1,
this.button1});
this.Name = "Form1";
this.Text = "RemoteObject";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}