|
nulls crash comparer
|
|
|
|
|
Hello ,
I have many question in mind to share with you.
1. Can one use the column header colored (every column color custmization)
2. Can one use the combobox/drop down as in header to sort.
3. Can one use the AutoFilter in listview?
Looking these question, the project seems to fulfill only a bit among byte.
Thanks & Regards
Anil Kumar
Anil Kumar
|
|
|
|
|
you make no sense.
1. can you cook a soft boiled egg?
2. can chickens fly?
Looking these question, the project seems to fulfill only a bit among byte.
what does irrelevant mean to you?
|
|
|
|
|
ME and U
When I Take a long time to finish,
I am slow,
When U takes a long time,
u r thorough
When I don't do it,
I am lazy,
When U does not do it,
u r busy,
When I do something without being told,
I am trying to
be smart,
When U does the same,
u takes the initiative,
When I please U,
I am apple polishing,
When U pleases ur boss,
u r cooperating,
When I make a mistake,
you're an idiot.
When U makes a mistake,
u'r only human.
When I am out of the office,
I am wondering around.
When U is out of the office,
u'r on business.
When I am on a day off sick,
I am always sick.
When U is a day off sick,
u must be very ill.
When I apply for leave,
I must be going for an
interview
When U applies for leave,
it's because u' r
overworked
When I do good,
U never remembers,
When I do wrong,
u never forgets
When I make a sense
You make no sense.
When I ask a question
U ask Can you cook a soft boiled egg?
When I ask More question
U still ask Can chickens Fly?
When i m looking these question
U seems only to fulfill only a bit among byte.
When nothing is irrelevant to me.
U ask what does irrelevant mean to u?
Finally i wanna to share that till u posted ur reply , i already solved 1 of 3 of my problems. and hope to solve all three when needed.
Anil
(PL)
Anil Kumar Sharma
(PL)
-- modified at 0:51 Tuesday 18th July, 2006
|
|
|
|
|
Is there a way to fix the problem when you sort by Date dd-MM-yyyy?
Thanks.
|
|
|
|
|
Hi,
You must import [vb] or use [c#] System.Threading & System.Globalization namespaces in the header of modul.
Then, in the constructor part of ur modul [ after InitialComponent()], you must set CultureInfo depending on ur country or you want. More info see MSDN with keyword 'CultureInfo".
Certainly, ur problem will be fixed 100% [like me before]. It's ok
May help u usefully.
Paula G.
|
|
|
|
|
Excellent, very clean solution.
Blogless
|
|
|
|
|
I have changed to use delegate in place of many classes. I believe clears the namespace up.
|
|
|
|
|
Hi, I was wondering if anyone out there might know how to convert the section of code to vb.net. I am getting an error "Unable to find an entry point named LoadLibrary in DLL kernel32.dll." when I call the lstviewsortManager. Thank you.
------------------------------------
C# Code
[DllImport("kernel32.dll")]
static extern IntPtr LoadLibrary(string fileName);
[DllImport("kernel32.dll", CharSet=CharSet.Ansi, ExactSpelling=true)]
public static extern UIntPtr GetProcAddress(IntPtr hModule, string procName);
[DllImport("kernel32.dll")]
static extern bool FreeLibrary(IntPtr hModule);
[DllImport("comctl32.dll")]
static extern int DllGetVersion(ref DLLVERSIONINFO pdvi);
static private bool ComCtlDllSupportsArrows()
{
IntPtr hModule = IntPtr.Zero;
try
{
hModule = LoadLibrary("comctl32.dll");
if(hModule != IntPtr.Zero)
{
UIntPtr proc = GetProcAddress(hModule, "DllGetVersion");
if(proc == UIntPtr.Zero) // Old versions don't support this method
return false;
}
DLLVERSIONINFO vi = new DLLVERSIONINFO();
vi.cbSize = Marshal.SizeOf(typeof(DLLVERSIONINFO));
DllGetVersion(ref vi);
return vi.dwMajorVersion >= 6;
}
finally
{
if(hModule != IntPtr.Zero)
FreeLibrary(hModule);
}
}
------------------------------------
VB.net Code
Private Declare Function LoadLibrary Lib "kernel32.dll" (ByVal fileName As String) As IntPtr
Public Declare Function GetProcAddress Lib "kernel32.dll" (ByVal hModule As IntPtr, ByVal procName As String) As UIntPtr
Private Declare Function FreeLibrary Lib "kernel32.dll" (ByVal hModule As IntPtr) As Boolean
Private Declare Function DllGetVersion Lib "comctl32.dll" (ByRef pdvi As DLLVERSIONINFO) As Integer
Private Shared Function ComCtlDllSupportsArrows() As Boolean
Dim hModule As IntPtr = IntPtr.Zero
Try
hModule = LoadLibrary("comctl32.dll") '***ERROR HERE - Unable to find an entry point named LoadLibrary in DLL kernel32.dll. ***
If Not (hModule.Equals(IntPtr.Zero)) Then
Dim proc As UIntPtr = GetProcAddress(hModule, "DllGetVersion")
If (proc.Equals(UIntPtr.Zero)) Then
Return False
End If
End If
Dim vi As DLLVERSIONINFO = New DLLVERSIONINFO
vi.cbSize = Marshal.SizeOf(GetType(DLLVERSIONINFO))
DllGetVersion(vi)
Return (vi.dwMajorVersion >= 6)
Finally
If Not (hModule.Equals(IntPtr.Zero)) Then
FreeLibrary(hModule)
End If
End Try
End Function
-----------------------------------------------
eatwork
|
|
|
|
|
I'm sure you've gotten your answer by now but for some that may not know in VB.NET a Declare Function of these types work best when you Automate them like this>>
Private Declare Auto Function LoadLibrary Lib "kernel32.dll" (ByVal fileName As String) As IntPtr
Public Declare Auto Function GetProcAddress Lib "kernel32.dll" (ByVal hModule As IntPtr, ByVal procName As String) As UIntPtr
Private Declare Auto Function FreeLibrary Lib "kernel32.dll" (ByVal hModule As IntPtr) As Boolean
Private Declare Auto Function DllGetVersion Lib "comctl32.dll" (ByRef pdvi As DLLVERSIONINFO) As Integer
|
|
|
|
|
small error for the GetProcAddress
it should be Ansi
Private Declare Ansi Function GetProcAddress Lib "kernel32.dll" (ByVal hModule As IntPtr, ByVal procName As String) As UIntPtr
|
|
|
|
|
I found that the arrows programatically drawn by this class are overwritten by the 0th and 1st images in the imagelist I have attached to my ListView. Has anyone else experienced this? I have debugged through the sort manager class all the way to the SendMessage to user32.dll, and the arrow bitmaps are successfully added to the imagelist created within the sort manager class, but the ListView displays images from the imagelist attached to it. I would appreciate some help.
Thanks!
MGrant
|
|
|
|
|
Thanks Eddie for the great code!
I added a code to prevent sorting of a column having null instead of a Comparer. Like this:
m_sortMgr = new ListViewSortManager(
m_list,
new Type[] { typeof(ListViewInt32Sort),
typeof(ListViewTextSort),
null,
typeof(ListViewDateSort)
},
0,
SortOrder.Ascending
);
To process this situation I added a check for null:
public void Sort(Int32 column, SortOrder order)
{
if (column < 0 || column >= m_comparers.Length)
throw new IndexOutOfRangeException();
if (m_comparers[column] == null)
return;
Regards
|
|
|
|
|
Good stuff, works splendidly.
Small typos in article:
m_sortMgr = new ListViewSortManager(m_list,
new Type[] {
typeof(ListViewTextSort),
typeof(ListViewTextCaseInsensitiveSort),
typeof(ListViewIntegerSort),
typeof(ListViewFloatSort),
typeof(ListViewDateSort)
}
);
Wout
|
|
|
|
|
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!
|
|
|
|
|