关于ListView显示不同颜色的问题 这里有ListView1和ListView2。 我想在双击ListView1中的某条数据的时候,在ListView2中,将与Listview相同的数据显示为红颜色,怎么写?在什么事件里写? 谢谢帮助! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls;type TForm1 = class(TForm) ListView1: TListView; ListView2: TListView; procedure ListView1CustomDrawItem(Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean); procedure ListView1DblClick(Sender: TObject); procedure ListView1Exit(Sender: TObject); private { Private declarations } public { Public declarations } setColor:Boolean; function a(Str:String):Boolean; end;var Form1: TForm1;implementation{$R *.dfm}{ TForm1 }function TForm1.a(Str: String): Boolean;begin if setColor then begin if str = Listview1.Selected.Caption then result := True else result := False; end else result := False;end;procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);begin if a(Item.Caption) then Listview2.Canvas.Brush.Color := clred else Listview2.Canvas.Brush.Color := clwindowend;procedure TForm1.ListView1DblClick(Sender: TObject);begin setColor := True; ListView2.Repaint;end;procedure TForm1.ListView1Exit(Sender: TObject);begin SetColor := False;end;end.{满不满意,哈哈,给分吧} hety(笨菜阿诺德) 谢谢你的提示 我该往哪个种语言发展啊???? 网络编程之WriteBuffer和WriteStream那种方法好? 现在应该选用哪个版本的DELPHI? 锁住屏幕,不接受按键和鼠标操作怎样实现那? 如何通过ADO访问foxfro数据库,能够不用ODBC而用OLE DB吗? 各位都用什么帮助工具制作应用程序的帮助文件啊? 怎样在一个按钮事件中生成可供全局使用的记录类型 网上哪里可以找到类似Decision cube的决策分析控件,支持ADO 高手、低手一起进来 这个主函数怎样去写? 软件使用权问题?ktv点歌系统 我连的是ACCESS库为什么一执行的时候总出一个密码进示框呀,?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;type
TForm1 = class(TForm)
ListView1: TListView;
ListView2: TListView;
procedure ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
procedure ListView1DblClick(Sender: TObject);
procedure ListView1Exit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
setColor:Boolean;
function a(Str:String):Boolean;
end;var
Form1: TForm1;implementation{$R *.dfm}{ TForm1 }function TForm1.a(Str: String): Boolean;
begin
if setColor then begin
if str = Listview1.Selected.Caption then
result := True
else result := False;
end else result := False;
end;procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
if a(Item.Caption) then
Listview2.Canvas.Brush.Color := clred
else
Listview2.Canvas.Brush.Color := clwindow
end;procedure TForm1.ListView1DblClick(Sender: TObject);
begin
setColor := True;
ListView2.Repaint;
end;procedure TForm1.ListView1Exit(Sender: TObject);
begin
SetColor := False;
end;end.
{
满不满意,哈哈,给分吧
}