Below code may help you,
private int X=0;
private int Y=0;
private int subItemSelected = 0 ;
public void ListView_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
li = this.GetItemAt(e.X , e.Y);
X = e.X ;
Y = e.Y ;
}
public void ListView_DoubleClick(object sender, System.EventArgs e)
{
int nStart = X ;
int spos = 0 ;
int epos = this.Columns[0].Width ;
for ( int i=0; i < this.Columns.Count ; i++)
{
if ( nStart > spos && nStart < epos )
{
subItemSelected = i ;
break;
}
spos = epos ;
epos += this.Columns[i+1].Width;
}
}
Console.WriteLine("SUB ITEM SELECTED = " +
li.SubItems[subItemSelected].Text);
subItemText = li.SubItems[subItemSelected].Text ;
string colName = this.Columns[subItemSelected].Text ;
}
Burke.
"TM" <Th**************@Yahoo.Com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
My Windows Form application has a ListView control, it has 3 columns. I
use onMouseUp event to capture the user's x,y mouse coordinates. How do I use
these X & Y to find out the excact column and the row number of thew
ListView control so that I can retrieve an item in it.
Example: string ls=myListView.Items[???].ToString(); The ??? is the index
point to the list items.
TIA
Thomas