Hi,
I would like to display all listview items in one row with scroll bar below it – instead of multiple rows and scroll bar on the right. Someone told me that I can achieve it using LVM_SETITEMPOSITION message.
According to my knowledge code below should set position for each item added to listView control. There are two ways of doing it - we can use MessageWindow.SendMessage from Microsoft.WindowsCE.Forms or use DllImport and SendMessage. For some unknown reason code is not working as expected and control displays items in multiple rows.
Could someone please help me ? - public static IntPtr MakeLParam(int wLow, int wHigh)
-
{
-
return (IntPtr)(((short)wHigh << 16) | (wLow & 0xffff));
-
}
-
-
-
[DllImport("coredll.dll", SetLastError = true)]
-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
-
-
const uint LVM_SETITEMPOSITION = 0x1000 + 15;
-
-
private void function()
-
{
-
-
ImageList imageList = new ImageList();
-
listView.View = System.Windows.Forms.View.LargeIcon;
-
-
-
-
try
-
{
-
-
int x = 0;
-
foreach ()
-
{
-
-
ListViewItem item = new ListViewItem(desc);
-
-
-
//magic
-
int index = listView.Items.Count;
-
-
-
-
IntPtr wparam = (IntPtr)index;
-
IntPtr lparam = MakeLParam(x, 0);
-
-
Message mes = Message.Create(listView.Handle, 0x1000 + 15, wparam, lparam);
-
MessageWindow.SendMessage(ref mes);
-
-
-
-
-
-
-
-
//old
-
//IntPtr listH = listView.Handle;
-
//int index = listView.Items.Count;
-
-
-
//int y = 0;
-
-
//int t = SendMessage(listH, LVM_SETITEMPOSITION, index, m);
-
//IntPtr t = SendMessage(listView.Handle, LVM_SETITEMPOSITION, (IntPtr)index, MakeLParam(x, y));
-
-
x += 20;
-
-
listView.Items.Add(item);
-
-
}
-
-
listView.LargeImageList = imageList;
-
-
}
-
catch (Exception ex)
-
{
-
-
}
-
}
2 6099 - public static IntPtr MakeLParam(int wLow, int wHigh)
-
{
-
return (IntPtr)(((short)wHigh << 16) | (wLow & 0xffff));
-
}
-
-
-
[DllImport("coredll.dll", SetLastError = true)]
-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
-
-
const uint LVM_SETITEMPOSITION = 0x1000 + 15;
-
-
private void function()
-
{
-
-
ImageList imageList = new ImageList();
-
listView.View = System.Windows.Forms.View.LargeIcon;
-
-
-
-
try
-
{
-
-
int x = 0;
-
foreach ()
-
{
-
-
ListViewItem item = new ListViewItem(desc);
-
-
-
//magic
-
int index = listView.Items.Count;
-
-
-
-
IntPtr wparam = (IntPtr)index;
-
IntPtr lparam = MakeLParam(x, 0);
-
-
Message mes = Message.Create(listView.Handle, 0x1000 + 15, wparam, lparam);
-
MessageWindow.SendMessage(ref mes);
-
-
-
-
-
-
-
-
//old
-
//IntPtr listH = listView.Handle;
-
//int index = listView.Items.Count;
-
-
-
//int y = 0;
-
-
//int t = SendMessage(listH, LVM_SETITEMPOSITION, index, m);
-
//IntPtr t = SendMessage(listView.Handle, LVM_SETITEMPOSITION, (IntPtr)index, MakeLParam(x, y));
-
-
x += 20;
-
-
listView.Items.Add(item);
-
-
}
-
-
listView.LargeImageList = imageList;
-
-
}
-
catch (Exception ex)
-
{
-
-
}
-
}
Hi,
Thank you, it seem that I should send message after
listView.Items.Add(item);.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Richard |
last post by:
Hi. I use a ListView to display data in tabular form.
Each ListView row corresponds to a data record.
The ListView Item of the record is the record key or code.
Each SubItem in that row...
|
by: suz |
last post by:
Hey,
I have a collection with custom objects. That collection
is bounded to a listview (I used the article of Lhotka).
The listview is also sortable.
I have also textboxes bound to the same...
|
by: Michael C |
last post by:
Hi all,
When I try to use the GetItemAt (e.X, e.Y) method in a ListView MouseDown()
event, it only works some of the time. If I right-click on an open area of
the ListView, I get null back as...
|
by: Maheshkumar.R |
last post by:
hi groups,
I have placed an listview control, i want to iterate thru the control and find the clicked event items.
listView2.Items.Add(fname.ToString(), i);
how i can perform the iteration...
|
by: Nick |
last post by:
Hi there,
I'm trying to implement drag-drop for my listview control in large icon
view mode. Unfortunately the order of the items gets completely messed up
upon inserting the item back into the...
|
by: Martin Horn |
last post by:
Hi all,
I want to implement a listview with editable subitems and I assume the
easiest way is to overlay a textbox over the item to be edited.
With this in mind I have come up with:
Using...
|
by: Droopy |
last post by:
Hi,
I got the System.ArgumentOutOfRangeException exception when adding an
item in ListView.
This ListView (listViewOutput) is used to display messages to user
(normal messages and error...
|
by: Archimed |
last post by:
Hi,
I try to use an ImageList with a ListView but that don't work.
I make a ListView in VirtualMode with LargeIcon view.
I put the ImageList in the LargeImageList property.
I add a bitmap...
|
by: Peter |
last post by:
Hi,
I have a problem with Listview using checkboxes.
If i check items by code BEFORE the form is shown the Listview.Items
are confused during the ItemChecked Event !!!
After showing the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |