Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Cancel SelectedIndexChanged event

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 11-06-2009
Member
 
Join Date: Jan 2009
Posts: 35
Cancel SelectedIndexChanged event
  

I would like to cancel SelectedIndexChanged event in ListView control. I tries the code with private function but didn't work :
Code:
Private void OnSelectedIndexChanged(object sender, EventArgs e) {

if ( <Condition not Allowed> ) {


ListView1.Items[0].Selected = true;

return;
}

}

Reply With Quote
  #2  
Old 11-06-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Cancel SelectedIndexChanged event

The SelectedIndexChanging event is raised when an item's Select button is clicked, but before the ListView control handles the select operation. Unfortunately, the ListView's SelectedIndexChanged event cannot be cancelled, and it's actually called for each change in the selection.
Reply With Quote
  #3  
Old 11-06-2009
Member
 
Join Date: Jan 2009
Posts: 199
Re: Cancel SelectedIndexChanged event

Code:
private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
if (mobj != null)
{
if (txtbx1.Text !=  mobj.Text)
{
e.Item.Selected = false;
mobj.Selected = true;

return;
}
}

if (listView1.SelectedItems.Count > 0)
{
txtbx1.Text = e.Item.Text;
mobj = e.Item;
}
else
{
txtbx1.Text = "";
 mobj = null;
}
}
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Cancel SelectedIndexChanged event"
Thread Thread Starter Forum Replies Last Post
Cancel reoccurring event in the future without losing per-event changes Chin-Mae Windows Software 5 16-10-2010 06:57 PM
Why does onclick event not cancel href navigation? Cordell Software Development 5 14-05-2010 12:03 AM
Cancel the onbeforeunload event in a webpage Brendan18 Software Development 4 21-05-2009 08:28 AM
Event ID: 5721 Event Source: NETLOGON member server windows 2003 Edwin Delgado Windows Server Help 1 08-09-2007 12:41 AM
Event Log Error: Event Source:WinMgmt Event ID:10 BlackSunReyes Small Business Server 2 01-03-2007 03:27 AM


All times are GMT +5.5. The time now is 09:22 AM.