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 

TlistView

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components
View previous topic :: View next topic  
Author Message
Skybuck Flying
Guest





PostPosted: Wed Feb 25, 2004 5:53 pm    Post subject: TlistView Reply with quote



Hi

I miss an event in TListView

TList.OnItemCheckboxClick or something like that Wink
Back to top
Skybuck Flying
Guest





PostPosted: Wed Feb 25, 2004 5:59 pm    Post subject: Re: TlistView Reply with quote



Ah yes found other newsgroup message.

This even should do the trick Razz*:D

procedure TFormMain.ListViewReceiverMulticastMembershipChanging(
Sender: TObject; Item: TListItem; Change: TItemChange;
var AllowChange: Boolean);

:)
Back to top
Skybuck Flying
Guest





PostPosted: Wed Feb 25, 2004 6:02 pm    Post subject: Re: TlistView Reply with quote



Actually this OnChange is better than OnChanging for what I want to do...

Otherwise it is vice versa :d

procedure TFormMain.ListViewReceiverMulticastMembershipChange(
Sender: TObject; Item: TListItem; Change: TItemChange);
begin

if (Change = ctState) then
begin
if Item.Checked then
begin
ShowMessage('checked');
end else
begin
ShowMessage('unchecked');
end;

end;

end;
Back to top
Skybuck Flying
Guest





PostPosted: Wed Feb 25, 2004 6:08 pm    Post subject: Re: TlistView Reply with quote

Hmmm seems like both events are needed to determine which property changed
:D

Since these events are used for different properies doh.
Back to top
Skybuck Flying
Guest





PostPosted: Wed Feb 25, 2004 6:33 pm    Post subject: Re: TlistView Reply with quote

Hmmm it's not as easy as it seems.

Many of these events occur.. which requires the checkbox checked state to be
stored for each list item !
Back to top
Skybuck Flying
Guest





PostPosted: Wed Feb 25, 2004 6:59 pm    Post subject: Re: TlistView Reply with quote

Ok,

I found the solution.

On adding and removing items prevent the OnChange and OnChanging events from
happening
( These will otherwise occur a lot and for different items. For example when
removing an item
some of these event will happen becomes a select property changed... and
then the checked
property of another item is assign to the boolean which you dont want Very Happy )


procedure ButtonAddOrRemoveClick Etc
var
TempOnChange : TLVChangeEvent;
TempOnChanging : TLVChangingEvent;
begin
// prevent OnChange and OnChanging events from happening
TempOnChange := ListView.OnChange;
TempOnChanging := ListView.OnChanging;

ListView.OnChange := nil;
ListView.OnChanging := nil;

// code to add or remove here

// re-enable On Change Event
ListView.OnChange := TempOnChange;
ListView.OnChanging := TempOnChanging;
end;


FormVariable:

var
mReceiverMulticastMembershipItemChecked

Then in OnChange:

procedure TFormMain.ListViewReceiverMulticastMembershipChange(
Sender: TObject; Item: TListItem; Change: TItemChange);
begin

if (Change = ctState) then
begin
// als deze twee verschillen dan is het verandert.
if (mReceiverMulticastMembershipItemChecked <> Item.Checked) then
begin

if Item.Checked then
begin
ShowMessage('checked');
end else
begin
ShowMessage('unchecked');
end;

mReceiverMulticastMembershipItemChecked := Item.Checked;
end;

end;

end;

And in onChanging:

procedure TFormMain.ListViewReceiverMulticastMembershipChanging(
Sender: TObject; Item: TListItem; Change: TItemChange;
var AllowChange: Boolean);
begin

if (Change = ctState) then
begin
mReceiverMulticastMembershipItemChecked := Item.Checked;
end;

end;


Hehe Smile works perfectly (for so far tested Smile Razz ) fucking yeah ! Very Happy
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components 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.