问题表现为:
手动设置里一点问题也没有,值和颜色都能正常显示,但是通过代码操作时,onchange事件并没有被触发.
解决方案是让它主动触发:
ComArr是个全局TList,窗体创建时,把这9个COMBOBOX加到里面去了.下面这段代码是用来'移动'色块的.
procedure TForm1.MoveModel(const K1, K2, K3: Integer); var i1, i2, i3: Integer; begin i1 := TComboBox(ComArr[K1]).ItemIndex; i2 := TComboBox(ComArr[K2]).ItemIndex; i3 := TComboBox(ComArr[K3]).ItemIndex; TComboBox(ComArr[K1]).ItemIndex := i2; SendMessage(TComboBox(ComArr[K1]).Handle,CN_COMMAND,MakeLong(0,CBN_SELCHANGE),0); TComboBox(ComArr[K2]).ItemIndex := i3; SendMessage(TComboBox(ComArr[K2]).Handle,CN_COMMAND,MakeLong(0,CBN_SELCHANGE),0); TComboBox(ComArr[K3]).ItemIndex := i1; SendMessage(TComboBox(ComArr[K3]).Handle,CN_COMMAND,MakeLong(0,CBN_SELCHANGE),0); end;
标签:值时,控件,ComArr,ComBoBox,K3,K2,K1,TComboBox,ItemIndex From: https://www.cnblogs.com/yoooos/p/17018556.html