Board index » cppbuilder » listview

listview


2004-07-22 02:23:24 PM
cppbuilder53
Hi,
i'm using the win32 listview control and i added an extended style to it to
drag and drop (LVS_EX_HEADERDRAGDROP) the headers so the user can setup the
columns any way they desire. i was wondering if there is a message that
exists that allows the re-ordering of columns? i want the ability to save
the order of the columns the user has so i can display it the same way when
then open the application again.
any ideas?
aloha,
mike
 
 

Re:listview

Hi Mike,
I don't know about the win32 but using the VCL TLIstView is straight
forward, and I would image it would be similar using the win32, after all
they are the same control at the end of the day (I think).
The TListColumn which represents each column has an Index property which
tells you the position in the TListColumns, i.e. the order. You can read
this property and store it somewhere and when you open the application again
you can set the Index for each column.
The TListView has an event called OnColumnDragged whech is fires when
someone moves a column.
I know this doesn't exactly answer your question, but I hope it helps a
little.
Dean
"mike" < XXXX@XXXXX.COM >wrote in message
Quote

Hi,

i'm using the win32 listview control and i added an extended style to it
to
drag and drop (LVS_EX_HEADERDRAGDROP) the headers so the user can setup
the
columns any way they desire. i was wondering if there is a message that
exists that allows the re-ordering of columns? i want the ability to save
the order of the columns the user has so i can display it the same way
when
then open the application again.

any ideas?

aloha,
mike


 

Re:listview

hi all
Is there any thing like "Listview" in java like we have in MFC and VB?
If not is there any simple way to get the same thing in java. I have come
across a short course on Sun's website
java.sun.com/developer/onlineTraining/GUI/Swing2/shortcourse.html
but it is very complex for me .
Thanks in advnce.
scorpio05678
 

{smallsort}

Re:listview

scorpio05678 < XXXX@XXXXX.COM >wrote:
Quote
Is there any thing like "Listview" in java like we have in MFC and VB?
If not is there any simple way to get the same thing in java.
See javax.swing.JList for a list control. Alternatively, you can use a
JTable set to column selection mode to display multiple columns of data
like details mode of a Windows list control. The model for both of
these components already works in an MVC manner, so there is no
equivalent to MFC's CListView, which is an adapter to MVC. JList is the
equivalent to CListCtrl with CListView built in.
Quote
I have come
across a short course on Sun's website
java.sun.com/developer/onlineTraining/GUI/Swing2/shortcourse.html
but it is very complex for me .
Ignore that. It has nothing to do with what you want.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Re:listview

I asked a similar question a couple of weeks ago in public.students group.
but now I have a more specific situation.
I have a TListView in vsReport mode. It has 4 columns,
OwnerData = true; Height = 150, Width = 250, rowSelect = true;
The code is below: I click Button1 before Button2.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ListView1->Items->Count = 100;
}
void __fastcall TForm1::ListView1Data(TObject *Sender, TListItem *Item)
{
int i = Item->Index;
Item->Caption = "row"+IntToStr(i);
Item->SubItems->Add(IntToStr(i)+"_0");
Item->SubItems->Add(IntToStr(i)+"_1");
Item->SubItems->Add(IntToStr(i)+"_2");
}
void __fastcall TForm1::Button2Click(TObject *Sender)
{
TListItem *Item;
char s[10];
int ind;
Item = ListView1->GetItemAt(0, ListView1->Height - 10); ///1
sprintf(s, "%p", Item);
Memo1->Lines->Add("Item: "+ AnsiString(s));
Memo1->Lines->Add("Item->Index="+IntToStr(Item->Index));
ind = ListView1->TopItem->Index + ListView1->VisibleRowCount; ///2
sprintf(s, "%p", Item);
Memo1->Lines->Add("Item: "+ AnsiString(s));
Memo1->Lines->Add("Item->Index="+IntToStr(Item->Index));
}
Line marked with (1) is used to get the last visible Item of the ListView.(I
know that
using ListView1->TopItem->Index and ListView1->VisibleRowCount is better,
but
forget it for a while)
The problem is: after the line marked with (2) Item->Index changes. Before
the line (2)
it returns the index of the last visible item as expected, but after line
(2) it returns the first visible item.
The pointer value of Item doesn't change but Item->Index changes.
If the line marked with (2) is not executed both the pointer value of Item
and Item->Index
don't change..
Any explanation what's going on?
Thanks...
 

Re:listview

"Umut Ozden" < XXXX@XXXXX.COM >wrote in message
Quote
The problem is: after the line marked with (2) Item->Index changes.
As well it should. TopIndex returns a TListItem pointer. When using
OwnerData=true, there is only one physical TListItem instance stored in
memory that gets reused for every TListItem-related operation. By accessing
the TopItem, it is returning the same internal TListItem instance that
GetItemAt() returned. The properties of that TListItem are overwritten by
new values from the OnData event handler when accessing the TopItem
property.
Quote
Before the line (2) it returns the index of the last visible item as
expected, but after line (2) it returns the first visible item.
Correct.
Quote
The pointer value of Item doesn't change but Item->Index changes.
Correct. The same physical TListItem instance is being reused, that is why
the pointer value does not change.
Quote
If the line marked with (2) is not executed both the pointer value
of Item and Item->Index don't change..
Correct.
I find that when using OwnerData=true, you need to use the Win32 API
directly in situations that cause the internal TListItem to change when you
don't want it to. So your previous example can be re-written as follows:
void __fastcall TForm1::Button2Click(TObject *Sender)
{
TListItem *Item = ListView1->GetItemAt(0, ListView1->Height - 10);
AnsiString s;
s.sprintf("%p", Item);
Memo1->Lines->Add("Item: "+ s);
Memo1->Lines->Add("Item->Index=" + IntToStr(Item->Index));
// using Win32 API here so that the TListView's internal TListItem
is not changed...
int ind = ListView_GetTopIndex(ListView1->Handle) +
ListView1->VisibleRowCount;
s.sprintf("%p", Item);
Memo1->Lines->Add("Item: "+ s);
Memo1->Lines->Add("Item->Index=" + IntToStr(Item->Index));
}
Gambit
 

Re:listview

Hello
Is it possible to have the ability of a partial search on the
TListview component? Lets say i have a few fields and in one field i
have the
word
Borland Builder
If i search for builder it will not find it, i have to search for the
entire word for it to work.
Is there a way to do this?
 

Re:listview

"startrak" < XXXX@XXXXX.COM >wrote:
Quote

[...] Lets say i have a few fields and in one field i have
the word

Borland Builder
<cough>
I hope you know that that is 2 words ... one string ... but
still 2 words.
Quote
If i search for builder it will not find it, i have to
search for the entire word for it to work.
That would be because of the compare function that you're
using. When all you want is a partial match, I would suggest
that you use strncmp because it compares at most n number of
characters. Without looking, I'd also guess that AnsiString
has a similar method as well.
~ JD
 

Re:listview

"startrak" < XXXX@XXXXX.COM >wrote in message
Quote
Is it possible to have the ability of a partial search on the
TListview component?
Sure it is. But you can't use the TListView's built-in search
capabilties for that, as they don't support what you are asking for.
So you will have to implement your own searching by looping through
the items yourself one at a time.
Gambit
 

Re:listview

Quote
So you will have to implement your own searching by looping through
the items yourself one at a time.
Could I have a StringList then search for the particular string in
there looping
thorugh in there, then display the result i.e. the Item in the ListView.
 

Re:listview

startrak wrote:
Quote
Could I have a StringList then search for the particular string in
there looping
thorugh in there, then display the result i.e. the Item in the
ListView.
Yes.
--
liz
 

Re:listview

"startrak" < XXXX@XXXXX.COM >wrote in message
Quote
Could I have a StringList then search for the particular string
in there looping thorugh in there, then display the result i.e. the
Item in the ListView.
You could. But you would have to loop through the ListView in order
to get the items into the StringList in the first place, so you may as
well search the ListView diectly while looping through it.
If you really want to search a StringList, then I suggest you store
all of your data in that StringList in the first place, and then set
the ListView to virtual mode (OwnerData=True with an OnData event
handler) so that the ListView can display the contents of the
StringList instead of its own items.
Gambit