473,385 Members | 1,641 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,385 software developers and data experts.

set coordinates to a ListViewItem

Hi everyone !

I would like to set an ListViewItem at a special position, into a ListView.
There is Bounds, but it's a propertie, that can be only get !
I would like to place the item at a special coordinates, not at a
special index.

like:

MFC: BOOL CListCtrl::SetItemPosition(int nItem, POINT pt);

thanks
Nov 16 '05 #1
7 3806
Hi!
Try to use LVM_SETITEMPOSITION.
Hope that helps.
Best regards.
Nov 16 '05 #2
Adrian wrote:
Hi!
Try to use LVM_SETITEMPOSITION.
Hope that helps.
Best regards.


ok , but how to send a message to a ListView ?
Nov 16 '05 #3
You use the SendMessage API call:
http://www.pinvoke.net/default.aspx/user32.SendMessage

"Herbert VON GRÜNENWALD" <he*******************@microsoft.com> wrote in
message news:42**************@microsoft.com...
Adrian wrote:
Hi!
Try to use LVM_SETITEMPOSITION.
Hope that helps.
Best regards.


ok , but how to send a message to a ListView ?

Nov 16 '05 #4
Declare as below the structure

[System.Runtime.InteropServices.StructLayout(System .Runtime.InteropServices.
LayoutKind.Sequential, Pack=2)]
public struct MAKELPARAM
{
public uint wLow;
public uint wHigh;
}

Import the method:

[System.Runtime.InteropServices.DllImport("User32.d ll")]
public extern static int SendMessage(IntPtr hwnd, uint message, int wparam,
MAKELPARAM lparam);

And finally, in a method, put the code:

MAKELPARAM M = new MAKELPARAM();
M.wHigh = x //New x-position of the item's upper-left corner, in view
coordinates.

M.wLow = y //New y-position of the item's upper-left corner, in view
coordinates. ;

int i = myitem;
SendMessage(listView1.Handle, 0x1000 + 15, i, M);

Hope that helps.
Best regards.
Nov 16 '05 #5
Adrian wrote:
Declare as below the structure

[System.Runtime.InteropServices.StructLayout(System .Runtime.InteropServices.
LayoutKind.Sequential, Pack=2)]
public struct MAKELPARAM
{
public uint wLow;
public uint wHigh;
}

Import the method:

[System.Runtime.InteropServices.DllImport("User32.d ll")]
public extern static int SendMessage(IntPtr hwnd, uint message, int wparam,
MAKELPARAM lparam);

And finally, in a method, put the code:

MAKELPARAM M = new MAKELPARAM();
M.wHigh = x //New x-position of the item's upper-left corner, in view
coordinates.

M.wLow = y //New y-position of the item's upper-left corner, in view
coordinates. ;

int i = myitem;
SendMessage(listView1.Handle, 0x1000 + 15, i, M);

Hope that helps.
Best regards.


[System.Runtime.InteropServices.DllImport("User32.d ll")]
public extern static <<int>> SendMessage(IntPtr hwnd, uint message, int
wparam,
MAKELPARAM lparam);
the compiler says that the <<int>> must be 'Class, delegate, enum,
interface or struct'

even with Int32

Nov 16 '05 #6
Declare inside the class, like below:

class Test
{
[System.Runtime.InteropServices.DllImport("User32.d ll")]
public extern static <<int>> SendMessage(IntPtr hwnd, uint message, int
wparam, MAKELPARAM lparam);
}

Hope that helps.
Best regards.
Nov 16 '05 #7
Adrian wrote:
Declare inside the class, like below:

class Test
{
[System.Runtime.InteropServices.DllImport("User32.d ll")]
public extern static <<int>> SendMessage(IntPtr hwnd, uint message, int
wparam, MAKELPARAM lparam);
}

Hope that helps.
Best regards.


thanks, i've declared the function inside a namespace...
Nov 16 '05 #8

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

Similar topics

0
by: LV | last post by:
Hello, I would like to manually set one of my list view items as selected. When this item is set, I would like for a method to execute. I have a delegate on the list view for SelectedIndexChanged....
0
by: afatdog | last post by:
I want to change the ListViewItem's StateImageIndex to change. private void Button_xx_Click(object sender, System.EventArgs e) { ListViewItem.StateImageIndex++; } But the ListViewItem's...
6
by: grs | last post by:
The following is a code example from the Microsoft MSDN. My question is on the following three lines of code: ListViewItem item1 = new ListViewItem("item1",0); ListViewItem item2 = new...
0
by: Kluch | last post by:
I am trying to select and focus single ListViewItem and can't seem to do so, here is my code: IEnumerator * itemList = mLsvMyList->Items->GetEnumerator(); while (itemList->MoveNext()) {...
1
by: Alan T | last post by:
I have a listview defined a coloumn at design time. And the code I use to add a listviewitem: ListViewItem lvi = new ListViewItem(user.Name); lvi.Tag = (Object)user.Id; ...
2
by: Kela | last post by:
An interesting problem: I have a ListView with LabelEdit set to TRUE. When I change the label, I want to make some decisions as to whether the ListViewItem (that's just been edited) should stay in...
0
by: garyusenet | last post by:
I am trying to create a form that will display a list of open internet explorer windows and allow the user to choose one of them. So far I have created an arraylist which contains all of the open...
13
by: deciacco | last post by:
How can I have access to the items collection of a listview control on my form from a background thread? I know I need delegates to update the listview control and I have those calls in the...
10
by: Gav | last post by:
I am trying to have a ListView to dispay a list of names and want to have an id stored within the list but not visable. I have tried to go about doing this by using the ListViewItem and setting...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.