Ext 的grid中怎么在第一列添加按钮?
答案:2 悬赏:20
解决时间 2021-02-19 19:02
- 提问者网友:空白
- 2021-02-18 18:07
Ext 的grid中怎么在第一列添加按钮?
最佳答案
- 二级知识专家网友:星星坠落
- 2021-02-18 18:18
tool 工具栏?
还是表格中的行啊?
还是表格中的行啊?
全部回答
- 1楼网友:情战辞言
- 2021-02-18 19:19
在listview的item上显示checkbox与button
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
type
pitemctrl = ^titemctrl
pitemctrl = record
checkbox: tcheckbox;
button: tbutton;
end;
end;
procedure tfrmmain.listview1customdrawsubitem(sender: tcustomlistview;
item: tlistitem; subitem: integer; state: tcustomdrawstate;
var defaultdraw: boolean);
var
rect: trect;
p: pitemctrl;
begin
{ 第2个子项目上显示checkbox,第5个子项目上显示button }
if subitem in [2, 5] then
begin
defaultdraw:= false; // 不显示默认的文本.
rect:= item.displayrect(drbounds); // 获取item显示的区域.
if item.data = nil then // 如果为空则创建checkbox及button.
begin
new(p); // 创建一个指针用于存储checkbox及button.
{ 创建并显示checkbox }
p.checkbox:= tcheckbox.create(listview1);
p.checkbox.parent:= listview1;
p.checkbox.caption:= ' ';
p.checkbox.width:= 20;
p.checkbox.height:= 20;
p.checkbox.left:= rect.right - listview1.columns[3].width
- listview1.columns[4].width - listview1.columns[5].width
- ((listview1.columns[2].width + p.checkbox.width) div 2);
p.checkbox.top:= rect.top;
p.checkbox.visible:= true;
{ subitems[2 -1].caption为0和1,直接转换为boolean型并给checkbox赋值. }
p.checkbox.checked:= strtobool(item.subitems[subitem -1]);
{ 创建并显示button }
p.button:= tspeedbutton.create(listview1);
p.button.parent:= listview1;
p.button.caption:= '... ';
p.button.width:= 20;
p.button.height:= 20;
p.button.left:= rect.right - ((listview1.columns[5].width
+ p.button.width) div 2);
p.button.top:= rect.top;
p.button.visible:= true;
item.data:= p; // 将checkbox及button的结构指针保存于item.data属性.
end;
end;
end;
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯