gpt4 book ai didi

C# Listbox设置选中项

转载 作者:太空狗 更新时间:2023-10-29 22:04:17 24 4
gpt4 key购买 nike

我有一个带有值的 C# 列表框

Profile 1
Profile 2
Profile 3

我想在加载表单时选择配置文件 2。我该怎么做?

最佳答案

设置ListBox.SelectedIndex Form.Shown 中的属性(property)事件。
例如:

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;
}

关于C# Listbox设置选中项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4453439/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com