473,804 Members | 3,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4967
"Li Pang" <Li****@discuss ions.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.Handl e, LVM_GETHEADER, 0, 0)

lret = SendMessage(hwn d, HDM_SETIMAGELIS T, 0,
(ImageList1.Han dle).ToInt32)
col.mask = LVCF_FMT Or LVCF_IMAGE
'col.fmt = LVCFMT_IMAGE Or LVCFMT_BITMAP_O N_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_Expli cit(0)

If showImage Then
'.fmt = HDF_STRING Or HDF_IMAGE Or HDF_BITMAP_ON_R IGHT
col.fmt = LVCFMT_STRING Or LVCFMT_IMAGE Or LVCFMT_BITMAP_O N_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.Handl e, 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****@discuss ions.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
23717
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 ). If possible, what do I do to activate that 'cell' - thanks. I thought that listView.LabelEdit = true; would enable me to navigate into the cells or something like listView.items .subitems.LabelEdit - but I did not see such a property....
2
10919
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 the sorting is done elsewhere, I just want the arrow! Thanks in advance
3
5895
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 sort order. How can I implement that? Thanks
2
2523
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 size. However, if the window (and thus the listview) is wider that the listview needs to be it makes the last column extra wide so that it fills the right side of the window.
12
7489
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 the overall size of the listview. My question therefore is, how can I tell if the items I have added will fit in the listview at its given height? A secondary one, just for interest sake...is there a way to determine the exact heght needed...
2
1792
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 is greater than the width of the column header's title then size the column to be the width of the data value. 2. If the width of the column header's title is greater than the width of the data in the column then size the column to be the width...
0
1438
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 sort arrow will appear but i want to replace it by another image or bitmap file. Is there any possiblity or any methods to override, so that we can place different arrow or image on the datagrid contol column header sort arrow look more prominent? ...
0
1576
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 sort arrow will appear but i want to replace it by another image or bitmap file. Is there any possiblity or any methods to override, so that we can place different arrow or image on the datagrid contol column header sort arrow look more prominent? ...
0
2317
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 form it is being used. I am using table in the listview control for formating purpose. In this table I want to hide a column. Is it posible to hide the column?. I am facing the problem because I cant catch the row its showing null values. ...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10571
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.