AI摘要

文章介绍了两种方法来实现ListView在选择行失去焦点后仍然保持高亮效果。第一种方法是设置ListView的hideselection属性为false。第二种方法是在ListView的onexit事件中绘制一个高亮背景,使用Canvas填充矩形区域,并设置颜色。代码示例中使用了红色作为高亮颜色,并在矩形区域内绘制文本。
文章介绍了两种方

两种解决方法:
设置listview的hideselection 属性
1、hideselection=false

2、绘制一个高亮背景
在listview的onexit事件中添加代码
  try
      item:=lv_userinfo.Selected;
      r:=Item.DisplayRect(drSelectBounds);
      with  TCustomListView(sender).Canvas do
      begin
        Brush.Color:=clRed;                        //此处设置为红色
        FillRect(r);
        TextOut(r.Left+2,r.Top+2,item.SubItems.Strings[0]+'        '+item.SubItems.Strings[1]+'       '+item.SubItems.Strings[2]+'        '+item.SubItems.Strings[3]+'       '+item.SubItems.Strings[4]);
      end;
  except
  end;



最后修改:2011 年 08 月 16 日
点赞的人是最酷的