 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
SAN CAZIANO Guest
|
Posted: Thu Oct 30, 2003 3:51 pm Post subject: how delete a TEdit from a series of TEdit and next scroll th |
|
|
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
|
Posted: Thu Oct 30, 2003 4:15 pm Post subject: Re: how delete a TEdit from a series of TEdit and next scrol |
|
|
"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
|
Posted: Thu Oct 30, 2003 4:18 pm Post subject: Re: how delete a TEdit from a series of TEdit and next scrol |
|
|
"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
|
Posted: Thu Oct 30, 2003 4:48 pm Post subject: Re: how delete a TEdit from a series of TEdit and next scrol |
|
|
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
|
Posted: Thu Oct 30, 2003 5:04 pm Post subject: Re: how delete a TEdit from a series of TEdit and next scrol |
|
|
"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
|
Posted: Fri Oct 31, 2003 3:13 pm Post subject: Re: how delete a TEdit from a series of TEdit and next scrol |
|
|
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 |
|
 |
|
|
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
|
|