Link to home
Start Free TrialLog in
Avatar of ibrobar
ibrobar

asked on

ListView

Hi All

My question is :

I am having a listview statring with 5 columns and I am filling it from a table or a query.During runtime I might Add new columns and i want to fill that specific columns with it's assigned data from the table without refilling the entire listview.
please anyone got a solution.

one more thing, what is the way to save a user layout for a listview , so each user can use his own layout for the columns in the listview

best regards

Avatar of Amir Azhdari
Amir Azhdari
Flag of United States of America image

Hi,
you can use a dynamic array of TlistView and create it in runtime something like to this:

var ListName:array of TlistView;

begin
   SetLength(ListName,10);
end;
that is not enough as setlength will only create the array but not initialize the listviews.

you will also have to
var ListName:array of TlistView;

begin
   SetLength(ListName,10);
  for i:=0 to length(listname0 do
    listname[i]:=TListView.Create(this);// for the current form
end;
hm .. that should teach me to read the question first. so sorry for the above anwser but that is NOT what you want.
you will only have to do something like this:

var l:TlistView; c:TListColumn; i:TCollectionItem;
begin
  c:=l.Columns.Add;
  c.Caption:='column name';
  for all rows to add do
  begin
    i:=c.Collection.Add;
    i.DisplayName:='value';
  end;
end;
regarding your second question:
you wil lhave to save yourself all data:
- listview sizes
- iterate through all columns and
--- save widths/other data
--- iterate through collection ffrom each column and
------- save all sizes/other data
Avatar of ibrobar
ibrobar

ASKER

thanks ciuly

can i get a DBlistview source code for delphi4 if you have it

regards
firstly, we cannot give out source code from delphi packages for obvious reasons. if I remember correctly, someone on another topic was working with you on something similiar, is it not?
secondly, your request is kind of off-topic :) and you already have a question open on this matter so you should find a solution there.
Avatar of ibrobar

ASKER

YES CIULY

you are right but the person i was working with wasn't able to give me the correct solution , besides that DBListView is not Borland code so we cann't fear copyright here it's a development tool.

thanks any way
actually we can fear copyright issues as the code should have some copyright or EULA or whatever. but unless you say which one you talk about, I cannot be sure.

but you are missing the point with that question and that is that you did not say which component you are looking for. there are a TON of DBListView compnents out there. you have to choose one.
OR, if you have one, you must give us information or link to it so that we can see what is the issue with it. we cannot help you unless you help us first by giving the info requested. let's move this discussion to that other thread (https://www.experts-exchange.com/questions/21857751/DBListView.html) for clarification.
also, we can discuss there why this solution (https://www.experts-exchange.com/questions/21857008/Delphi-Source.html) doesn't work for you since you already accepted it.

cheers
Avatar of ibrobar

ASKER

Hi i tried this code

var l:TlistView; c:TListColumn; i:TCollectionItem;
begin
  c:=l.Columns.Add;
  c.Caption:='column name';
  for all rows to add do
  begin
    i:=c.Collection.Add;
    i.DisplayName:='value';
  end;
end;

but it didn't work .

regards
don't tell me you run that piece of code just the way it is... it was just a sketch, I hope that was obvious. if not for other reason then for the syntactical errors at compilation time.
if you did implement real code based on the sketh you should post it and also metnion what and where is the error so we can help you ;)
Avatar of ibrobar

ASKER

Hi Ciuly

Afcourse i didn't use the code as it is . But let me just ask you about the loop:  For I:=0 to listview1.items.count-1 do it it right


thanks

regards
ASKER CERTIFIED SOLUTION
Avatar of 2266180
2266180
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ibrobar

ASKER

I will try it today

thanks