Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-12

TValueListEditor example

8 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart
to Richard Mace

Hi,

Please could someone give me an example of how to programmatically add column and then items into a TValueListEditor?

You cannot (maybe you can, but you really should NOT) add colums to TValueListEditor.
It will always have exactly 2 colums by design.

Adding items isn't that hard.

The easiest way is to add the Key/Value pair to the Strings property:

ValEdit.Strings.Add('MyValue=AValue');

If you want you can hav teh Value column for this item behave like a dropdownlist:

  with ValEdit.ItemProps['MyValue'] do
  begin
    KeyDesc := 'MyValue: PickList';  //optional description
    EditStyle := esPickList;
    ReadOnly := True;  //user cannot add options to dropdownlist
    PickList.Add('AValue');
    PickList.Add('AnotherValue');
  end;

Bart

Reply by email

Richard Mace
to Bart

Bart,
Many thanks for your reply, it's starting to make sense now :) It is possible to make the "key" column read only?

Richard

Bart wrote 36 lines
Hi, > Please could someone give me an example of how to programmatically add column and then > items into a TValueListEditor? You cannot (maybe you can, but you really should NOT) add colums to TValueListEditor. It will always have exactly 2 colums by design. Adding items isn't that hard. The easiest way is to add the Key/Value pair to the Strings property: ValEdit.Strings.Add('MyValue=AValue'); If you want you can hav teh Value column for this item behave like a dropdownlist: with ValEdit.ItemProps['MyValue'] do begin KeyDesc := 'MyValue: PickList'; //optional description EditStyle := esPickList; ReadOnly := True; //user cannot add options to dropdownlist PickList.Add('AValue'); PickList.Add('AnotherValue'); end; Bart -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131215/99031bf3/attachment.html>

Reply by email

Bart
to Richard Mace
Richard Mace wrote
It is possible to make the "key" column read only?

Look at KeyOptions property.
If you exclude KeyEdit from it, the Key column will not be editable by the user.

You can set it in OI or by code:

ValEdit1.KeyOptions := ValEdit1.KeyOptions - [KeyEdit];

Bart

Reply by email

Richard Mace
to Bart

Hi Bart,
Many thanks for your reply.

Bart wrote 7 lines
> It is possible to make the "key" column read only? Look at KeyOptions property. If you exclude KeyEdit from it, the Key column will not be editable by the user.

I've done that, but it is still editable?
I'm using Lazarus 1.012 and Windows XP?

Thanks for looking into this for me

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131216/d0c910bb/attachment.html>

Reply by email

Bart
to Richard Mace
Richard Mace wrote
> If you exclude KeyEdit from it, the Key column will not be editable by I've done that, but it is still editable?

Works for me in trunk.

I have attached a test suite I use for development of ValEdit. Build and run.

Please check with 1.2 RC1 or trunk.

Check or UnCheck the Keyedit checkbox and see the result. If you encounter a situation where thecheckbox for Keyedit is UnChecked and you still can edit, then please press the speedbutton with the questionmark (?).
It'll write down the actual value of KeyEdit in KeyOptions. If that also says FALSE, then report back:
The status of all checkboxes.

Bart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vle.zip
Type: application/zip
Size: 5619 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131216/308386fc/attachment-0001.zip>

Reply by email

Richard Mace
to Bart

Hi Bart,
Yes, all working in Trunk
Thanks for all of your hard work.

Richard

Show quoted text 22 lines
>> If you exclude KeyEdit from it, the Key column will not be editable by > I've done that, but it is still editable? Works for me in trunk. I have attached a test suite I use for development of ValEdit. Build and run. Please check with 1.2 RC1 or trunk. Check or UnCheck the Keyedit checkbox and see the result. If you encounter a situation where thecheckbox for Keyedit is UnChecked and you still can edit, then please press the speedbutton with the questionmark (?). It'll write down the actual value of KeyEdit in KeyOptions. If that also says FALSE, then report back: The status of all checkboxes. Bart

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131217/ebea8ded/attachment.html>

Reply by email