我在speedbutton1的onclick里面写了如下代码if speedbutton1.down then being 
  speedbutton1.down:=false;
  speedbutton1.groupindex:=0;
endelse
being
  speedbutton1.down:=true;
  speedbutton1.groupindex:=1;
end;
 
  speedbutton1.groupindex的初始值为1;
  speedbutton1.dowm为假
我在第一次和第二次使用的时候一切正常,再进行时就没有变化了,下断点后发现
程序停在了  speedbutton1.groupindex:=0;有高人帮忙看看,明天结贴给分

解决方案 »

  1.   

    设置GROUPINDEX为1就一切OK了;你ONCLICK的代码没必要;
      

  2.   

    Allows speed buttons to work together as a group.Delphi syntax:property GroupIndex: Integer;C++ syntax:__property int GroupIndex = {read=FGroupIndex, write=SetGroupIndex, default=0};DescriptionSet GroupIndex to determine how the button behaves when clicked. When GroupIndex is 0, the button behaves independently of all other buttons on the form. When the user clicks such a speed button, the button appears pressed (in its clicked state) and then returns to its normal up state when the user releases the mouse button.When GroupIndex is greater than 0, the button remains selected (in its down state) when clicked by the user. When the user clicks a selected button, it returns to the up state, unless Caption is false. Setting the GroupIndex property of a single speed button to a value greater than 0 causes the button to behave as a two-state button when Caption is true.Speed buttons with the same GroupIndex property value (other than 0), work together as a group. When the user clicks one of these buttons, it remains selected until the user clicks another speed button belonging to the same group. Speed buttons used in this way can present mutually exclusive choices to the user.
      

  3.   

    用outer2000(天外流星)的方法就可以了
      

  4.   

    只需定义一个只含有一个按钮的组(GroupIndex属性),并将他的AllowAllUp设为Ture即可,不需写代码。
      

  5.   

    方法很多的拉
    简单的直接象楼上改属性
    复杂的直接用一个bool类型,每次点击来回改变它的值就可以了
      

  6.   

    同意用outer2000(天外流星)的方法。不要简单问题复杂化。
      

  7.   

    楼上说得很对,是  yuzhantao(找不到女朋友,只好养条狗)想得太复杂了.
    而且代码也用不着这么多呀.看我的吧.一行代码搞定.SpeedButton1.GroupIndex:= SpeedButton1.GroupIndex XOR 1;