请教关于TCheckListBox的问题
jieyh 2005-10-29 11:30:56 我定义了一个结构
struct st
{
int a;
bool b;
};
在初始化TCheckListBox控件时我用如下语句
st* st1=new st;
for(int item=0;item<10;item++)
{
st1->a=item;
st1->b = item%2==0?true:false;
checklistbox1->AddItem("adsf",(TObject*)st1);
}
我在OnClickCheck中当选择不同是获取他的st1的值我用的语句如下但总是获取到最后一次增加的st1值
st* tempst = (st*)checklistbox1->Items->Objects[checklistbox1->ItemIndex];
我希望的结果是当选择第一个时
tempst->a=0;
tempst->b=true;
选择第二个时
tempst->a=1;
tempst->b=false;
但我在程序中获取的无论我选择第几项都是得到
tempst->a=9;
tempst->b=false;
请高手指点~~
谢谢!!!