set coordinates to a ListViewItem

  • Thread starter Thread starter =?ISO-8859-1?Q?Herbert_VON_GR=DCNENWALD?=
  • Start date Start date
?

=?ISO-8859-1?Q?Herbert_VON_GR=DCNENWALD?=

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
 
Adrian said:
Hi!
Try to use LVM_SETITEMPOSITION.
Hope that helps.
Best regards.

ok , but how to send a message to a ListView ?
 
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.dll")]
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.
 
Adrian said:
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.dll")]
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.dll")]
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
 
Declare inside the class, like below:

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

Hope that helps.
Best regards.
 
Adrian said:
Declare inside the class, like below:

class Test
{
[System.Runtime.InteropServices.DllImport("User32.dll")]
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...
 
Back
Top