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 

how delete a TEdit from a series of TEdit and next scroll th

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





PostPosted: Thu Oct 30, 2003 3:51 pm    Post subject: how delete a TEdit from a series of TEdit and next scroll th Reply with quote



I have a series of TEdit one behind the other (first.top =10;
second.top=40; third.top=70.... )
If I delete a TEdit (free it ) over a form, I have to reduce the TOP of all
the TEdit behind it (to simply reduce the top property)

example:

EDIT1
EDIT2
EDIT3
EDIT4


if I delete Edit2, then Edit3 reduce it's top Property to Edit2 and next
Edit4 reduce it's top Property to Edit3

thanks,


Back to top
Ian Kirk
Guest





PostPosted: Thu Oct 30, 2003 4:15 pm    Post subject: Re: how delete a TEdit from a series of TEdit and next scrol Reply with quote



"SAN CAZIANO" <akalb.sia (AT) tiscalinet (DOT) it> wrote

Quote:
I have a series of TEdit one behind the other (first.top =10;
second.top=40; third.top=70.... )
If I delete a TEdit (free it ) over a form, I have to reduce the TOP of
all
the TEdit behind it (to simply reduce the top property)

example:

EDIT1
EDIT2
EDIT3
EDIT4


if I delete Edit2, then Edit3 reduce it's top Property to Edit2 and next
Edit4 reduce it's top Property to Edit3

Something along the lines of:

iDeletedTop := Edit2.Top ;
Edit2.Free ;

for i := 0 to ComponentCount - 1 do begin
if (Components[i] is TEdit) and (Components[i].Top > iDeletedTop) then
Components[i].Top := Components[i].Top - 30 ;
end ;

HTH,
Ian



Back to top
Ignacio Vazquez
Guest





PostPosted: Thu Oct 30, 2003 4:18 pm    Post subject: Re: how delete a TEdit from a series of TEdit and next scrol Reply with quote



"SAN CAZIANO" <akalb.sia (AT) tiscalinet (DOT) it> wrote in message
[email]3fa1353d (AT) newsgroups (DOT) borland.com[/email]...
Quote:
I have a series of TEdit one behind the other (first.top =10;
second.top=40; third.top=70.... )
If I delete a TEdit (free it ) over a form, I have to reduce the TOP of
all the TEdit behind it (to simply reduce the top property)

What about putting the TEdits on separate panels with .Align set to alTop
and then freeing the entire panel?

Cheers,
Ignacio

--
The strange part isn't so much that he had an accent. No accent was
detectable. It was just sounds and burbs and gurgles coming from him. He
was a like a chubby, old R2-D2.
- La Üter



Back to top
SAN CAZIANO
Guest





PostPosted: Thu Oct 30, 2003 4:48 pm    Post subject: Re: how delete a TEdit from a series of TEdit and next scrol Reply with quote

Thanks for both solution, but I think the second has less problem, but get
more resources, so I think to use the first (of IAN) and so I create this

procedure RefreshAfterDeleteFromSeries(AForm:TForm; DeletedEdit:TEdit);
var
i:integer;
DeletedTop:integer;
begin
DeletedTop:=DeletedEdit.Top;
DeletedEdit.Free;
for i:=0 to AForm.ComponentCount - 1 do
begin
if (AForm.Components[i] is TEdit) and ((AForm.Components[i] as
TEdit).Top > DeletedTop) then
(AForm.Components[i]as TEdit).Top:=(AForm.Components[i]as TEdit).Top -
31 ;
end;
end;

my problem is that I create in runtime all the Edit, next I fill a ListBox
with all the caption of the Edit created and next if I click the selected
row of the listbox
I have to call the procedure but I can't assign the DeletedEdit because I
think i will have to find it by the row caption of the listbox...

so the DeletedEdit is ???


"Ian Kirk" <ian (AT) kel (DOT) removethis.co.uk> wrote

Quote:

"SAN CAZIANO" <akalb.sia (AT) tiscalinet (DOT) it> wrote in message
news:3fa1353d (AT) newsgroups (DOT) borland.com...
I have a series of TEdit one behind the other (first.top =10;
second.top=40; third.top=70.... )
If I delete a TEdit (free it ) over a form, I have to reduce the TOP of
all
the TEdit behind it (to simply reduce the top property)

example:

EDIT1
EDIT2
EDIT3
EDIT4


if I delete Edit2, then Edit3 reduce it's top Property to Edit2 and next
Edit4 reduce it's top Property to Edit3

Something along the lines of:

iDeletedTop := Edit2.Top ;
Edit2.Free ;

for i := 0 to ComponentCount - 1 do begin
if (Components[i] is TEdit) and (Components[i].Top > iDeletedTop) then
Components[i].Top := Components[i].Top - 30 ;
end ;

HTH,
Ian





Back to top
Ian Kirk
Guest





PostPosted: Thu Oct 30, 2003 5:04 pm    Post subject: Re: how delete a TEdit from a series of TEdit and next scrol Reply with quote

"SAN CAZIANO" <akalb.sia (AT) tiscalinet (DOT) it> wrote

Quote:
Thanks for both solution, but I think the second has less problem, but get
more resources, so I think to use the first (of IAN) and so I create this

procedure RefreshAfterDeleteFromSeries(AForm:TForm; DeletedEdit:TEdit);
var
i:integer;
DeletedTop:integer;
begin
DeletedTop:=DeletedEdit.Top;
DeletedEdit.Free;
for i:=0 to AForm.ComponentCount - 1 do
begin
if (AForm.Components[i] is TEdit) and ((AForm.Components[i] as
TEdit).Top > DeletedTop) then
(AForm.Components[i]as TEdit).Top:=(AForm.Components[i]as
TEdit).Top -
31 ;
end;
end;

my problem is that I create in runtime all the Edit, next I fill a ListBox
with all the caption of the Edit created and next if I click the selected
row of the listbox
I have to call the procedure but I can't assign the DeletedEdit because I
think i will have to find it by the row caption of the listbox...

so the DeletedEdit is ???

As well as the captions in the listbox you can associate an object reference
with each item in the list, and in your case this could be a reference to
the TEdit corresponding to that item. Use the AddObject method to add the
string and object reference combination - for example (with invented
variables and lists):

for i := 0 to iNEdits - 1 do begin
anEdit := GetEdit(i) ;

// Add edit box's text, and the reference to the edit itself
aListBox.Items.AddObject(anEdit.Text, anEdit) ;
end ;

Going back to your code, to extract DeletedEdit use:

DeletedEdit := aListBox.Items.Objects[aListBox.ItemIndex] As TEdit ;

HTH,
Ian



Back to top
Iain Macmillan
Guest





PostPosted: Fri Oct 31, 2003 3:13 pm    Post subject: Re: how delete a TEdit from a series of TEdit and next scrol Reply with quote

In article <3fa142a1 (AT) newsgroups (DOT) borland.com>, "SAN CAZIANO"
<akalb.sia (AT) tiscalinet (DOT) it> wrote:

Quote:
my problem is that I create in runtime all the Edit,
Oh right.. good!

would it help instead of creating a bunch of edits to create an Array of
TEdit, (and a counter) so that your alignment routine just goes something
like:
for i:=1 to EditCount do TheEdits[i].Top:=i*20;
A similar loop would repopulate the listbox, and deletion would just be a
matter of shuffling the later array elements up by one and dec'ing the
counter.

Quote:
so the DeletedEdit is ???
TheEdits[TheListbox.itemindex+1]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using 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.