G
Guest
I tried using the 'Leave event' on my ListView to deselect the selected
record, but the control only triggers the 'Leave event' when the user clicks
on another interactive control. What I want is when the user clicks the mouse
at ALL, for my program to check what control it clicked on and if its NOT
within my listBox, then the current selected record of ListBox should be
deselected. I tried using the frmMain_MouseDown event, but that only works
when the mouse clicks specifically on the form. I need to use the event
called when the mouse clicks ANYWHERE within that window... on any control.
Here is the code I used...
private void frmMain_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if(!sender.Equals(listOne))
this.listOne.FocusedItem.Selected = false;
}
...listOne is my listview control
It works only when I click on the background of my window. What can I do?
record, but the control only triggers the 'Leave event' when the user clicks
on another interactive control. What I want is when the user clicks the mouse
at ALL, for my program to check what control it clicked on and if its NOT
within my listBox, then the current selected record of ListBox should be
deselected. I tried using the frmMain_MouseDown event, but that only works
when the mouse clicks specifically on the form. I need to use the event
called when the mouse clicks ANYWHERE within that window... on any control.
Here is the code I used...
private void frmMain_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if(!sender.Equals(listOne))
this.listOne.FocusedItem.Selected = false;
}
...listOne is my listview control
It works only when I click on the background of my window. What can I do?