Click here to Skip to main content
15,907,687 members
Home / Discussions / C#
   

C#

 
GeneralRe: Hiding Form on Startup Pin
Ista31-Jul-03 6:57
Ista31-Jul-03 6:57 
GeneralRe: Hiding Form on Startup Pin
Adam Durity31-Jul-03 8:35
Adam Durity31-Jul-03 8:35 
GeneralAutoScroll jumping to 0 Pin
S O S31-Jul-03 5:01
S O S31-Jul-03 5:01 
GeneralRe: AutoScroll jumping to 0 Pin
misterbear31-Jul-03 22:59
misterbear31-Jul-03 22:59 
GeneralListView and user click Pin
aeros31-Jul-03 4:21
aeros31-Jul-03 4:21 
GeneralRe: ListView and user click Pin
Rampas Tomas31-Jul-03 17:41
Rampas Tomas31-Jul-03 17:41 
GeneralRe: ListView and user click Pin
aeros31-Jul-03 22:44
aeros31-Jul-03 22:44 
GeneralRe: ListView and user click Pin
Rampas Tomas1-Aug-03 3:31
Rampas Tomas1-Aug-03 3:31 
You are right. We have to help ourselves with interop:

class YourClassName<br />
{<br />
  const int LVM_FIRST  = 0x1000;<br />
  const int LVM_GETSUBITEMRECT = (LVM_FIRST + 56);<br />
  const int LVIR_BOUNDS = 0;<br />
  const int LVIR_ICON = 1;<br />
<br />
  [StructLayout(LayoutKind.Sequential)]<br />
  struct RECT<br />
  {<br />
    public int left;<br />
    public int top;<br />
    public int right;<br />
    public int bottom;<br />
  };<br />
  [DllImport("user32.dll")]<br />
  private static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, ref RECT lParam );<br />
  <br />
private void listView1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
  RECT myrect;<br />
  ListViewItem lvitem = listView1.FocusedItem;<br />
  int wParam = lvitem.Index;<br />
  int intLVSubItemIndex;<br />
  ListViewItem.ListViewSubItem LVSubItem = null;<br />
  int intSendMessage;<br />
<br />
  for( intLVSubItemIndex = 1; intLVSubItemIndex < lvitem.SubItems.Count; intLVSubItemIndex++)<br />
  {<br />
    LVSubItem = lvitem.SubItems[intLVSubItemIndex];<br />
    myrect = new RECT();<br />
    myrect.top = intLVSubItemIndex;<br />
    myrect.left = LVIR_BOUNDS;<br />
    intSendMessage = SendMessage(listView1.Handle, LVM_GETSUBITEMRECT, wParam, ref myrect);<br />
    if( e.X < myrect.left)<br />
    {<br />
	LVSubItem = lvitem.SubItems[0];<br />
	intLVSubItemIndex = 0;<br />
	break;<br />
    }<br />
    else if(e.X >= myrect.left && e.X <= myrect.right)<br />
    {<br />
	break;<br />
    }<br />
    else<br />
	LVSubItem = null;<br />
  }<br />
<br />
  if (LVSubItem != null && lvitem != null)<br />
  {<br />
    MessageBox.Show(String.Format("ColumnIndex: {0} {1}", intLVSubItemIndex,<br />
			LVSubItem.Text));<br />
  }<br />
<br />
<br />
}<br />
}<br />


In the intLVSubItemIndex you have 0 base index of clicked column.


Tomas Rampas
------------------------------
gedas CR s.r.o.
System analyst, MCP
TGM 840,
293 01 Mlada Boleslav,
Czech Republic
Telefon/phone +420(326)711411
Telefax/fax +420(326)711420
rampas@gedas.cz
http://www.gedas.com/
------------------------------

To be or not to be is true...
George Bool
Generalscaling text to fit into rectangle Pin
misterbear31-Jul-03 4:13
misterbear31-Jul-03 4:13 
Generalhelp!! about the ListView Pin
vvvmmmvvv31-Jul-03 4:10
vvvmmmvvv31-Jul-03 4:10 
GeneralRe: help!! about the ListView Pin
Rampas Tomas31-Jul-03 17:10
Rampas Tomas31-Jul-03 17:10 
GeneralConvert string into expression Pin
JM_FL31-Jul-03 3:22
JM_FL31-Jul-03 3:22 
GeneralRe: Convert string into expression Pin
Nick Seng31-Jul-03 15:34
Nick Seng31-Jul-03 15:34 
Generalwindows service written in C++, COM objects, call from C# Pin
alma31-Jul-03 3:11
alma31-Jul-03 3:11 
GeneralRe: windows service written in C++, COM objects, call from C# Pin
alma31-Jul-03 23:20
alma31-Jul-03 23:20 
Generalrunning function in Form from UserControl Pin
Hovik Melkomian31-Jul-03 1:23
Hovik Melkomian31-Jul-03 1:23 
GeneralRe: running function in Form from UserControl Pin
Rampas Tomas31-Jul-03 2:09
Rampas Tomas31-Jul-03 2:09 
GeneralRe: running function in Form from UserControl Pin
Hovik Melkomian3-Aug-03 2:40
Hovik Melkomian3-Aug-03 2:40 
GeneralRe: running function in Form from UserControl Pin
Rampas Tomas3-Aug-03 21:34
Rampas Tomas3-Aug-03 21:34 
GeneralRe: running function in Form from UserControl Pin
Hovik Melkomian4-Aug-03 2:54
Hovik Melkomian4-Aug-03 2:54 
GeneralRe: running function in Form from UserControl Pin
Rampas Tomas4-Aug-03 3:38
Rampas Tomas4-Aug-03 3:38 
GeneralRe: running function in Form from UserControl Pin
Hovik Melkomian4-Aug-03 3:53
Hovik Melkomian4-Aug-03 3:53 
GeneralRe: running function in Form from UserControl Pin
Hovik Melkomian4-Aug-03 3:22
Hovik Melkomian4-Aug-03 3:22 
GeneralRe: running function in Form from UserControl Pin
Rampas Tomas4-Aug-03 3:48
Rampas Tomas4-Aug-03 3:48 
GeneralRe: running function in Form from UserControl Pin
Hovik Melkomian4-Aug-03 4:13
Hovik Melkomian4-Aug-03 4:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.