for I := 0 to ListBox1.Items.Count -1 do
  begin
    if ListBox1.Selected[I] then ListSelectItem := I;
    ListBox1.Selected[I] := False;
  end;
ListBox1.Selected[ListSelectItem] := True;

解决方案 »

  1.   

    ListBox1这是个ListBox,我不知道在D下的Selected这个属性在VB.NET下有没有。
      

  2.   

    实际上我是想实现当我点击ListBox空白处的时候,能让ListBox选中状态都变成未选中状态。默认的情况下点击空白的地方,上一次选中的行数还是有蓝底的。 
    上面我的代码在D下是通过的,是可以实现我所要的结果,但在VB.Net不知道应该怎么写哪位帮忙下呢
      

  3.   

    for I = 0 to ListBox1.Items.Count -1 do  
        if ListBox1.Selected[I] is True then ListSelectItem = I 
        else 
          ListBox1.Selected[I] = False 
        end if 
    end for 
    if ListSelectItem >=0 and ListSelectItem <=ListBox1.Items.Count -1 
    ListBox1.Selected[ListSelectItem] = True 
    end if