有一个按钮,他的作用完成:
1:使listview控件的指定的项(不是子项)处于选中状态,(即鼠标单击的状态,改项为蓝色背景,白色文字)
2:然后使这一项处于可编辑状态,就是出现一个编辑的方框,输入焦点在方框内。整个过程模拟鼠标单击选中指定的项,然后再单击,使这一项处于可编辑状态,不知如何实现?请大侠们执教

解决方案 »

  1.   

    1.把RowSelect属性设定为True2.
    ListView & TreeView 的绘制:procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);varp:trect;beginif cdsselected in state thenbeginlistview1.Canvas.Font.Color:=clgreen;listview1.Canvas.brush.Color:=clred;p:=item.displayrect(drselectbounds);listview1.Canvas.FillRect(p);listview1.Canvas.Textout(p.Left+2,p.Top,item.Caption);listview1.Canvas.brush.Color:=clblue;listview1.Canvas.FrameRect(item.displayrect(drselectbounds));defaultdraw:=false;end;end;
      

  2.   


     ListView1.Items[i].EditCaption;
     i 為你要改的項的索引
      

  3.   

    1。类似这样的代码应该可以吧:
      TreeView1.Perform(TVM_SELECTITEM,TVGN_CARET,TreeView1.Items[0].GetHandle);
    你可以查阅MSDN的TVM_SELECTITEM。
    2。  TreeView1.Perform(TVM_EDITLABEL,0,TreeView1.Items[0].GetHandle);
    你可以查阅MSDN的TVM_EDITLABEL。
      

  4.   

    1.RowSelection:=True
      HideSelection:=False
    2.ListView1.IsEditing:=True