Ozz*_*zzy 5 c# listbox selected listboxitem winforms
我有一个带有值的C#列表框
Profile 1
Profile 2
Profile 3
Run Code Online (Sandbox Code Playgroud)
我想在表单加载时选择配置文件2.我该怎么做呢?
Don*_*nut 19
ListBox.SelectedIndex在Form.Shown事件中设置属性.
例如:
public Form1()
{
InitializeComponent();
// Adding the event handler in the constructor
this.Shown += new EventHandler(Form1_Shown);
}
private void Form1_Shown(object sender, EventArgs e)
{
myListBox.SelectedIndex = 1;
}
Run Code Online (Sandbox Code Playgroud)
在Form.Loaded事件中放入以下代码:
listBox1.SelectedItem = "Profile 2";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29011 次 |
| 最近记录: |