473,394 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Add an arrow onto listView header column

Hi,

I used some code to add an arrow icon onto a listview header column for the
sorting purpose. However, after the icon added, the TextAlign of the column
becomes "left", if I enforced TextAlign = right, the icon disppeared. Is
somebody has a solution?

Thanks
Nov 21 '05 #1
2 4931
"Li Pang" <Li****@discussions.microsoft.com> schrieb:
I used some code to add an arrow icon onto a listview header column for
the
sorting purpose. However, after the icon added, the TextAlign of the
column
becomes "left", if I enforced TextAlign = right, the icon disppeared. Is
somebody has a solution?


How did you add the icon?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #2
Hi,

Here the function I used to add the arrow onto the column header:

Private Sub ShowHeaderIcon(ByVal colNo As Integer, ByVal imgIconNo As
Integer, ByVal showImage As Boolean)

Dim hwnd As IntPtr
Dim lret As IntPtr
Dim i As Integer
Dim col As LVCOLUMN
'Assign the ImageList to the header control.
'The header control includes all columns.
'Get a handle to the header control.
hwnd = SendMessage(Me.ListView1.Handle, LVM_GETHEADER, 0, 0)

lret = SendMessage(hwnd, HDM_SETIMAGELIST, 0,
(ImageList1.Handle).ToInt32)
col.mask = LVCF_FMT Or LVCF_IMAGE
'col.fmt = LVCFMT_IMAGE Or LVCFMT_BITMAP_ON_RIGHT
'The image to use from the Image List.
'col.iImage = iconImage ' first image
col.cchTextMax = 0
col.cx = 0
col.iOrder = 0
col.iSubItem = 0
col.pszText = IntPtr.op_Explicit(0)

If showImage Then
'.fmt = HDF_STRING Or HDF_IMAGE Or HDF_BITMAP_ON_RIGHT
col.fmt = LVCFMT_STRING Or LVCFMT_IMAGE Or LVCFMT_BITMAP_ON_RIGHT
'.iImage = imgIconNo
col.iImage = imgIconNo 'iconImage ' first image
Else
'.fmt = HDF_STRING
col.fmt = LVCFMT_STRING
End If
'Send the LVM_SETCOLUMN message.
'The column to which you are assigning the image is defined in the
third parameter.
lret = SendMessage(Me.ListView1.Handle, LVM_SETCOLUMN, colNo, col)

End Sub

As you can see the icon is added ate the right of the header title. It works
fine when the column textalign = left, but got the trunble when the
textalign= right.
"Herfried K. Wagner [MVP]" wrote:
"Li Pang" <Li****@discussions.microsoft.com> schrieb:
I used some code to add an arrow icon onto a listview header column for
the
sorting purpose. However, after the icon added, the TextAlign of the
column
becomes "left", if I enforced TextAlign = right, the icon disppeared. Is
somebody has a solution?


How did you add the icon?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: andrewcw | last post by:
The clcik event on the ListView control seems to trigger off the item level ( the first column ). I would like to be able to trap the click event on a particular subitem ( a specific column's row...
2
by: Dan | last post by:
Hi, I would like my list view controls column headers to display a "down arrow / triangle" to indicate by which column they are sorted. I don't want the ListView to actually sort any data as...
3
by: Steve | last post by:
I have windows form with ListView control. The ListView control has few columns which user can sort by clicking the column header. I want the column header have the small triangle indicator of...
2
by: Just Me | last post by:
Listview is Docked=Fill I set all column widths to -2 and it works as expected if the listview needs to be too wide for the window. That is, I get an H-scrollbar and the columns are the correct...
12
by: J L | last post by:
When I fill a listview, I resize the columns to fit the data. I need to know if the data will fit vertically or if there will be a vertical scroll bar. I need to know this so I can allow for it on...
2
by: Steve Randall | last post by:
I have a listview control containing a number of columns. When I populate the listview columns with data I want to size each column according to the following rules: 1. If the width of the data...
0
by: Reddy4All | last post by:
Hi- Is there any possiblity to make Datagrid control (Winforms) column header sort arrow more prominent in .net 2003. In Windows forms Datagrid control, when user click on the column header, default...
0
by: Reddy4All | last post by:
Hi- Is there any possiblity to make Datagrid control (Winforms) column header sort arrow more prominent in .net 2003. In Windows forms Datagrid control, when user click on the column header, default...
0
by: bharathreddy | last post by:
Hi All, I am using a listview control in my usercontrol so that it can be used in more than one form. This user control has one column extraw, so i want to make it invisible depending on the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.