我是一个新手,就是在form中让listbox的任一项为选中状态,需要什么代码啊?

解决方案 »

  1.   

    this.listBox1.SetSelected(itemIndex, true);
    其中的itemIndex是要选中项的序号(从0开始)
      

  2.   

    ListBox.SelectIndex=ListBox.Items.Count-1;
      

  3.   


    listBox1.SelectedItem = "列表中的文字";
      

  4.   

    this.listBox1.SetSelected(itemIndex, true); 这个看起来像是正解;
      

  5.   

    this.listBox1.SelectedIndex = 0;//选中单个,这里为第一项。
      

  6.   

    this.listBox1.SetSelected(itemIndex, true);
    ListBox.SelectIndex=数字;
    listBox1.SelectedItem = 一个object对象()这写基本上都可以弄,在listBox 控件中,select打头的方法或属性都可以设置,设置属性也可以改变选中的状态
      

  7.   

    ListBox.SelectIndex=0;就是选中第一行
    哈 或其他行 类似
      

  8.   

    this.listBox1.SetSelected(itemIndex, true); 
      

  9.   

    this.listBox1.SetSelected(itemIndex, true); 
    ListBox.SelectIndex=数字; 
    listBox1.SelectedItem = 一个object对象() 
      

  10.   


    this.listBox1.SetSelected(itemIndex, true);
    ListBox.SelectIndex=itemIndex;
      

  11.   

          private void Form1_Load(object sender, EventArgs e)
            {
                this.listBox1.SelectedIndex = 2;//楼主呀在这个事件里你就可以直接设置哪行被选中了,2为第三行
            }试试我的办法。