吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2395|回复: 9
收起左侧

[求助] delphi 10.3.1中ValueListEditor控件

[复制链接]
冥界3大法王 发表于 2019-8-5 11:31
本帖最后由 冥界3大法王 于 2019-8-5 11:33 编辑

我为什么不能选择第一列的数据项?
Snap10.jpg
我无法得到 第一列的 选中项呢?  不知该如何设置

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

sail2000 发表于 2019-8-5 13:43
本帖最后由 sail2000 于 2019-8-5 13:47 编辑

第一列是字段名,第二列才是属性值,
你要改字段名?那么这个不合适。
你要改属性值,激活所要的属性值即可。
r如果你想要的是整行高亮选择:设置 :
ValueListEditor1.Options :=  ValueListEditor1.Options + [goRowSelect];
 楼主| 冥界3大法王 发表于 2019-8-5 13:45
sail2000 发表于 2019-8-5 13:43
第一列是字段名,第二列才是属性值,
你要改字段名?那么这个不合适。
你要改属性值,激活所要的属性值即 ...

上面的做到了,如何得到选中的 表格数值呢?
试了下面的代码 都不满意

[Delphi] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
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
unit Unit1;
 
interface
 
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids,
  Vcl.ValEdit, Vcl.StdCtrls;
 
type
  TForm1 = class(TForm)
    ValueListEditor2: TValueListEditor;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure ValueListEditor2Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to ValueListEditor2.RowCount - 1 do
    ShowMessage(ValueListEditor2.Keys[I]);
end;
 
procedure TForm1.Button2Click(Sender: TObject);
var
  txt: string;
begin
  txt := 'key1=value1' + #13 + 'key2=value2' + #13 + 'key3=value3';
  ValueListEditor2.Strings.Text := txt;
  showmessage(ValueListEditor2.Strings.Text);
end;
 
procedure TForm1.ValueListEditor2Click(Sender: TObject);
var
  str: string;
begin
//  str := ValueListEditor2.keys[3];
//  ShowMessage(str);
 
  ShowMessage(ValueListEditor2.Keys[ValueListEditor2.row]);
  ShowMessage(ValueListEditor2.Cells[1, 2]);
  ShowMessage(ValueListEditor2.Strings.Text);
end;
 
end.
sail2000 发表于 2019-8-5 13:55
[Delphi] 纯文本查看 复制代码
1
2
3
4
5
6
var
  i: integer;
begin
  i := ValueListEditor1.Row;
  ShowMessage('这是 Key:' + ValueListEditor1.Keys[i] + #10#13 + '这是 Value:' +
  ValueListEditor1.Values[ValueListEditor1.Keys[i]]);
 楼主| 冥界3大法王 发表于 2019-8-5 14:05
sail2000 发表于 2019-8-5 13:55
[mw_shl_code=delphi,true]var
  i: integer;
begin



@sail2000
好像有点bug哟
我把工程和生成的文件 都传上来了,再帮助我修改下,谢谢。
 楼主| 冥界3大法王 发表于 2019-8-5 14:13
为啥 弹出的结果是 B1 B2 这样的两个?
我需要的效果是 点击B1 弹出B1。。。B2弹B2
还是这个组件都必须是一一对应的一组数据?
xinyuguy 发表于 2019-8-6 10:43
你用 click  必然 这样啊  ,那不是 有 选择 事件吗  ,  当前焦点事件 也是可以啊  。  
sail2000 发表于 2019-8-6 12:59
[Delphi] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
procedure TForm1.ValueListEditor2Click(Sender: TObject);
var
  I,C: integer;
begin
  i := ValueListEditor2.Row;
  C := ValueListEditor2.Col;
  if C = 0 then
    ShowMessage(ValueListEditor2.Keys[i])
  else
   if C = 1 then
    ShowMessage(ValueListEditor2.Values[ValueListEditor2.Keys[i]]);
end;

免费评分

参与人数 1吾爱币 +4 热心值 +1 收起 理由
冥界3大法王 + 4 + 1 很巧妙,佩服~~

查看全部评分

 楼主| 冥界3大法王 发表于 2019-8-6 16:30
sail2000 发表于 2019-8-6 12:59
[Delphi] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
procedure TForm1.ValueListEditor2Click(Sender: TObject);
var
  I,C: integ ...[/quote]
 
[mw_shl_code=delphi,true]procedure TForm1.ValueListEditor2Click(Sender: TObject);
var
  i: integer;
  clip: TClipboard;
  strs: TStrings;
begin
  i := ValueListEditor2.Row;
 
  strs := TStringList.Create;
  strs.CommaText := ValueListEditor2.Keys[i];
 
  clip := TClipboard.Create;
  clip.AsText := strs[0] + ' ' + strs[1];
 
  ShowMessage(strs[2] + #13#10#13#10 + strs[0] + ' ' + strs[1] + ' 已经复制到剪贴板!');
  ////////////////////////////////////////////////////////////////////////////////
  clip.AsText := ValueListEditor2.Values[ValueListEditor2.Keys[i]];
  ShowMessage(ValueListEditor2.Values[ValueListEditor2.Keys[i]] + #13#10#13#10 + ' 已经复制到剪贴板!');
end;

这个控件,只能显示2列;所以暂时鼓捣成了这个样子。
Snap15.jpg
感觉注解字符串,用正则来提取更方便些

 楼主| 冥界3大法王 发表于 2019-8-6 16:31
本帖最后由 冥界3大法王 于 2019-8-6 18:09 编辑

本楼,重了,作废。
Snap15.jpg
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-5-25 13:29

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表