BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

treeview selection mutually exclusive

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Roger L. Main
Guest





PostPosted: Mon Dec 08, 2003 4:55 pm    Post subject: treeview selection mutually exclusive Reply with 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:

{ 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





PostPosted: Mon Dec 08, 2003 5:08 pm    Post subject: Re: treeview selection mutually exclusive Reply with quote



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





PostPosted: Tue Dec 09, 2003 10:15 am    Post subject: Re: treeview selection mutually exclusive Reply with quote



"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.


Quote:
Any advice?

Don't use OnMouseDown. Use an event that is actually related to
_selecting_ nodes. OnChange comes to mind.

Groetjes,
Maarten Wiltink



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.