|
When I populate my list I set the forecolor to gray for each item. When the form is loaded the items display correctly, all gray. But after clicking a column to sort, the first item in the list looses its color property. Any clue why?
|
|
|
|
|
Hallo,
first thing - I really like this project. It helped me save an awful lot of time, first in developping such a tool by myself and second in applying it to my projects. Thank's a lot.
But just now I detected some strange behaviour - it's not really a bug it's just a bit annoying:
If you have a listview with everything set and all the items added during design-time, everything works fine.
But as soon as you instantiated the ListViewSortManager in the constructor of your main-class - as proposed in this article - and add your items in reaction of some event the user fired, the text in the columnheaders will disappear as soon as you click on the header to sort the column. It will reappear though as soon as you click on another column to sort this one. So you see what I mean: It's not really a bug - it is rather not the way the user expects a listview to work.
But there is a workaround: As soon as you do the instantiation of the manager AFTER adding all contents to the listview everything will work fine.
Again - thank you for you sharing your ideas and your work with us,
achim
|
|
|
|
|
Hello Everyone,
I am getting this problem as well, I've tryed the work around you suggested (instantiating it after filling my ListView with values), however, still having the problem. It's more than a little annoying, I need it to work correctly. I'm not using a stand alone form, my form is embedded in a tab control and I'm wondering if that has something to do with it because when using it in just a plain form it works fine. I've tryed everything I could think of with no results. I'm using VB .Net 2003 and if anyone has any suggestions, they would be greatly appreciated!!
BTW: I really love the ease of use of this project, just wish I could get it to work for my situation, I really think it would be a waste to re-write it.
Heather
|
|
|
|
|
okay, so I fixed my problem, hopefully this will help someone else in the future.
My list view that I am using the Sorting class on is contained within another form. I was initializing my list view form (i.e. calling the sort manager) through it's parent form and apparently this was causing the sort manager to not work correctly.
So in order to fix this, i had to call the sort manager from within the form containing the list view instead of the form containing the form in the list view.
lol kind of tricky and I'm not sure why it worked that way but I fixed it.
ps i'm using vb .net 2003
|
|
|
|
|
Nobody knew the solution, or another implementation to fix this bug on this software??? The MISTERIUS DISAPPEARING COLUMN HEADER????
|
|
|
|
|
I have tried these fixes and the text still disappears on mine. I call a function in my constructor to load all of the data into the listview, and then i instantiate the listviewsortmanager after this. Also, when i run my program, the column headers do not display the sort arrow when they are clicked on. Any ideas?
|
|
|
|
|
Looks like I found solution. It seems that the problem is with ImageList. It is set to ColumnHeader in the constructor but when ShowHeaderIcon method is called it is not there... So the solution which works with me is to do ImageList initialization in the ShowHeaderIcon method(the original code of ShowHeaderIcon was slightly modified by me...):
private void ShowHeaderIcon(ListView list_, int columnIndex_, SortOrder sortOrder_)
{
if(list_ == null || columnIndex_ < 0 || columnIndex_ >= list_.Columns.Count)
return;
ColumnHeader colHdr = list_.Columns[columnIndex_];
Win32API.HDITEM hd = new Win32API.HDITEM();
hd.mask = Win32API.HDI_FORMAT | Win32API.HDI_IMAGE;
hd.iImage = (int)sortOrder_ - 1;
hd.fmt = Win32API.HDF_STRING;
switch(colHdr.TextAlign)
{
case HorizontalAlignment.Left:
hd.fmt |= Win32API.HDF_LEFT | Win32API.HDF_BITMAP_ON_RIGHT;
break;
case HorizontalAlignment.Center:
hd.fmt |= Win32API.HDF_CENTER | Win32API.HDF_BITMAP_ON_RIGHT;
break;
case HorizontalAlignment.Right:
hd.fmt |= Win32API.HDF_RIGHT;
break;
}
if(sortOrder_ != SortOrder.None)
hd.fmt |= Win32API.HDF_IMAGE;
if (_imgList == null)
{
_imgList = new ImageList();
_imgList.ImageSize = new Size(8, 8);
_imgList.TransparentColor = Color.Magenta;
_imgList.Images.Add(GetArrowBitmap(ArrowType.Ascending)); // Add ascending arrow
_imgList.Images.Add(GetArrowBitmap(ArrowType.Descending));// Add descending arrow
SetHeaderImageList(_list, _imgList);
}
IntPtr hHeader = Win32API.SendMessage(list_.Handle, Win32API.LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
Win32API.GetHDITEM(hHeader, Win32API.HDM_SETITEM, new IntPtr(columnIndex_), ref hd);
}
|
|
|
|
|
Nice piece of work. Only I found that setting the transparant property of listview.items.smallimagelist is not working anymore. Does anyone have a solution.
thnx tim
|
|
|
|
|
Hello,
It's me once again!
I'd like to have multiple sorting (by ctrl+clicking on columns, sort by column 2 then by column 4 then by column 3). Do you have something already? Are you planning to implement it?
Here are some other ideas that I plan to add to your class once I have some free time:
* Multiple sorting if you don't have something already
* Support for a total row (at least it would always be at the end (and in bold) when sorted)
* Allow column reordering
* Return all column widths/column order as a string so they can be saved somewhere (even autosave to an XML file).
* Restore column width/order from that string (and a restore defaults)
* Export to XML (I already have that working)
I think, with those features, we would have a really great list view enhancer. Any more ideas?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi,
To be honest I have no current plans to enhance this control since I haven't been doing any .NET lately.
The list of features you suggest seem like useful additions, so if you want to discuss them so we can implement them together, or if you want to go on your own it all right with me too.
A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine. - Murphy's Law of Computing
|
|
|
|
|
A current project is requiring multiple sort, so I guess I'll roll up my sleeves and implement it this week. I will add it to your class, and later post the result here (probably as an article.)
You can be my beta tester!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Cool. One thing though... why not put your changes into this article to avoid branching the project? I'll happily add you as a co-author of the article
A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine. - Murphy's Law of Computing
|
|
|
|
|
I was thinking of a new article because sorting would be only one of the "many" features of the list view manager class (not just list view sorting manager).
However, multiple sort is something I need right now, so I'll implement it and send it to you so you can add it to this article. Later, when I get to implement the other features (for example, there's something about saving column order in another article here -- I'd probably use that) we can decide if it belongs in here or in a new article.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
well any luck?
i:m going to do sth in vs2k5
|
|
|
|
|
Yes, I actually did it. I sent it to Eddie for review, but he never got back to me. I am still pending on writing the article, but I have yet to find the time.
I didn't get your email address on the notification mail I received, but you should get mine in the notification you will receive from this post. Email me and I will send you the code.
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
|
|
|
|
|
Thanks Eddie for this extremely usefull library.
I am trying to use it in my .NET 2.0 Public Beta 2 project, but arrows do not appear in the column headers. Any suggestions?
Thanks again...
Metin Albayrak
|
|
|
|
|
I see the same problem with the final VS2005. No arrows are drawn in the column headers.
Best regards
Bo
|
|
|
|
|
|
|
So easy to use.
Thank your for sharing your work!
-Chris
|
|
|
|
|
You are very welcome and I'm glad to hear that you liked it. Thanks
A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine. - Murphy's Law of Computing
|
|
|
|
|
I had to change the following line from public to internal when I included your code in a CLS Compliant class library.
[DllImport("kernel32.dll", CharSet=CharSet.Ansi, ExactSpelling=true)]
internal static extern UIntPtr GetProcAddress(IntPtr hModule, string procName);
|
|
|
|
|
Thanks for spotting this. Actually all these imports should have been made private. It will be fixed in the next update.
A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine. - Murphy's Law of Computing
|
|
|
|
|
Hi,
I was using Application.EnableVisualStyles() to enable XP Style theme for my form, but if i create a ListViewSortManager in the constructor and then launch a new form the XP Visual Style is disabled for some weird reason. Do you have any idea as to why?
Regards,
Vedavyas K.P
Your Anger is a Gift
|
|
|
|
|
It's a Visual Studio bug (I only noticed it when using C#)
Just add this line after Application.EnableVisualStyles();
Application.DoEvents();
|
|
|
|