Show sort header arrow and image in listview 2.0
-
Hi... In my application I have some listviews. I wanted to improve their appeareance adding an image to the headers. This is easy using smallimagelist of the listview class. The problem is that I want to show the sort arrow. For this I do it in this way:
IntPtr hHeader = Win32.SendMessage(this.Handle,Win32.LVM_GETHEADER,IntPtr.Zero,IntPtr.Zero); . . (more code) . . . Win32.SendMessage2(hHeader,Win32.HDM_SETITEM,new IntPtr(columnIndex),ref hd);
But when I click a header, the images dissapears. Does anybody know a solution for this issue? thanks -
Hi... In my application I have some listviews. I wanted to improve their appeareance adding an image to the headers. This is easy using smallimagelist of the listview class. The problem is that I want to show the sort arrow. For this I do it in this way:
IntPtr hHeader = Win32.SendMessage(this.Handle,Win32.LVM_GETHEADER,IntPtr.Zero,IntPtr.Zero); . . (more code) . . . Win32.SendMessage2(hHeader,Win32.HDM_SETITEM,new IntPtr(columnIndex),ref hd);
But when I click a header, the images dissapears. Does anybody know a solution for this issue? thanksHello I assume you are using dllImport to send that message to your header cell. Why?? You can use
myList.Columns[X].ImageIndex
to show the arrow in your imagelist and change the arrow image in theColumnClick
event. Anyway, if you still want to use messages, try to resend the message in the click event handler. PS. What isWin32.SendMessage
?? Where do you put the above code? Did you handle the ColumnClick event?? If so what do you do in it concerning the painting?Regards:rose:
-
Hello I assume you are using dllImport to send that message to your header cell. Why?? You can use
myList.Columns[X].ImageIndex
to show the arrow in your imagelist and change the arrow image in theColumnClick
event. Anyway, if you still want to use messages, try to resend the message in the click event handler. PS. What isWin32.SendMessage
?? Where do you put the above code? Did you handle the ColumnClick event?? If so what do you do in it concerning the painting?Regards:rose:
Of course, I´m using dllimport and I handled the ColumClick event. Win32 is only a class that hosts dllimports and other stuff. I know I can use ImageIndex to show the arrow. But... what I want is...to show an image and the arrow, at the same time. What I want is something like this: http://www.codeproject.com/cs/miscctrl/XPTable.asp. But with listview 2.0. kind regards and thanks for your answer
-
Hello I assume you are using dllImport to send that message to your header cell. Why?? You can use
myList.Columns[X].ImageIndex
to show the arrow in your imagelist and change the arrow image in theColumnClick
event. Anyway, if you still want to use messages, try to resend the message in the click event handler. PS. What isWin32.SendMessage
?? Where do you put the above code? Did you handle the ColumnClick event?? If so what do you do in it concerning the painting?Regards:rose:
Using the native sending of messages is uncalled for here. It is vanishing because the same init is not being persisted. You need to couple creation message with every other message, if you insist in sending antive messages. Though i can see two more ways of achieving the same result, though from unmanaged apps.
Excelsior Arjun Bahree "By The Might of Mjolnir" I Came! I Coded! I Conquered!
-
Of course, I´m using dllimport and I handled the ColumClick event. Win32 is only a class that hosts dllimports and other stuff. I know I can use ImageIndex to show the arrow. But... what I want is...to show an image and the arrow, at the same time. What I want is something like this: http://www.codeproject.com/cs/miscctrl/XPTable.asp. But with listview 2.0. kind regards and thanks for your answer
Hello Well, one easier solution is: 1- Get the image from your ImageList; 2- Use a Graphics object to draw the arrow with the proper direction at the proper place of the image. 3- Show the image in your header!! This way you won't need to use unmanaged calls!!
Regards:rose: