 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Roger L. Main Guest
|
Posted: Mon Dec 08, 2003 4:55 pm Post subject: treeview selection mutually exclusive |
|
|
Help please.
I have a treeview control that can only ever have two levels: parent
and children. I want to adjust the control so that the user can only
ever select the parent or one or more children, but not both. The code
I used is:
{ sort of pseudo-code }
procedure treeview_mousedown Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var node: ttreenode;
i: integer;
begin
node := treeview.getnodeat (x, y);
if (node = nil) then exit;
if (node.parent <> nil) then begin
node.parent.selected := false;
exit;
end;
for i := 0 to (node.count - 1) do
node.items [i].selected := false;
end {treeview_mousedown};
This is logically correct, but when I implement it it results in weird
behaviour, noteably - if a parent is selected and I ctrl-select a
child node, the child node gets deselected and the parent remains
selected.
Any advice?
|
|
| Back to top |
|
 |
Jeremy Collins Guest
|
Posted: Mon Dec 08, 2003 5:08 pm Post subject: Re: treeview selection mutually exclusive |
|
|
Roger L. Main wrote:
| Quote: | Help please.
I have a treeview control that can only ever have two levels: parent
and children. I want to adjust the control so that the user can only
ever select the parent or one or more children, but not both. The code
I used is:
Any advice?
|
Have you tried setting MultiSelect to False?
--
jc
Remove the -not from email
|
|
| Back to top |
|
 |
Maarten Wiltink Guest
|
Posted: Tue Dec 09, 2003 10:15 am Post subject: Re: treeview selection mutually exclusive |
|
|
"Roger L. Main" <roger.main (AT) widgetinc (DOT) com> wrote
| Quote: | I have a treeview control that can only ever have two levels: parent
and children. I want to adjust the control so that the user can only
ever select the parent or one or more children, but not both. The code
I used is:
|
<snip code that seems to deselect parent first>
| Quote: | This is logically correct, but when I implement it it results in weird
behaviour, noteably - if a parent is selected and I ctrl-select a
child node, the child node gets deselected and the parent remains
selected.
|
I doubt that it is logically correct. Things are probably happening in
an unforeseen (by you) sequence that throws off your logic.
Don't use OnMouseDown. Use an event that is actually related to
_selecting_ nodes. OnChange comes to mind.
Groetjes,
Maarten Wiltink
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|