问一个ListView的Checkboxs的简单问题

 所属目录:Java   |   类型:技术问答   |   时间:2007-05-21
 问题:

listview1的checkboxs=true;  
  操作中,我对其中某些行勾上;  
  问:我怎么知道我当前勾上的是那个?

· 网友精彩回答:

发表者:hcann

take   it   easy!  
   
        int       i_count   =   listview1->items->count;  
        for   (int   i=0;   i<i_count;   i++)  
        {  
                    if   (listview1->selected[i]==true)  
                    //处理此被勾上行...  
        }

发表者:meteor_tent

listview1->selected[i]==true  
  就是列表中某一项被选上了吧

发表者:caoruomou

控件数组:  
   
  for   (int   i=0;i<40;i++)  
  {  
  if(dynamic_cast<checkbox*>(findcomponent("checkbox"=inttostr(i)))->checked)  
  //put   your   code   here  
  }  
   
   
  另一个方法:  
  int   k=this->controlcount;  
  for(   int   i=0;i<k;i++)  
  {  
  if(this->controls[i]->classnameis("tcheckbox"))  
  {  
  tcheckbox*   p=dynamic_cast   <tcheckbox*>   (this->controls[i]);  
  string   strcaption=p->caption;  
  int   benable=p->checked;  
  if(query1->active)   query1->close();  
  query1->sql->clear();  
  query1->sql->add("insert   into   menuenableornot   (me_u_id,me_menu_name,me_enable)   values   ("+labid->caption+","+strcaption+","+benable+")");  
  query1->execsql();  
   
  }  
  }

发表者:zhuia

急你就不会隔了差不多三天才回复了!  
  你试试这个事件,自己算坐标吧。还有,listview1的字体大小改变,行宽也会改变的。还要注意,在选择一行后,按空格键也能改变checkboxs状态。  
  void   __fastcall   tform1::listview1mousedown(tobject   *sender,  
              tmousebutton   button,   tshiftstate   shift,   int   x,   int   y)

.
处理 SSI 文件时出错
© 2006-2008 All Rights Reserved