Hi,
If you want to do some processing before the SelectedIndexChanged you
should use the MouseDown event, now the real trick is knowing where it was
clicked.
With a listview it's very easy as the ListViewItem provide a bound
property.
In a listbox, well take a look at this piece of code from opennetcf.org 's
OwnerDrawControl:
protected override void OnMouseDown(MouseEventArgs e)
{
//get out if there are no items
if (listItems.Count == 0)
return;
int prevSelection = selectedIndex;
selectedIndex = this.vScroll.Value + (e.Y / this.ItemHeight);
Graphics gxTemp = this.CreateGraphics();
if (prevSelection!=-1)
PaintItem(gxTemp, prevSelection);
PaintItem(gxTemp, selectedIndex);
DrawBorder(gxTemp);
//this.Focus();
base.OnMouseDown( e);
if ( prevSelection != selectedIndex)
OnSelectedIndexChanged( e);
}
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"KK" <kr*****@lucidindia.net> wrote in message
news:Ow*************@TK2MSFTNGP11.phx.gbl...
Hi All...
For my purpose, I need to handle listbox selection changed event.I
must be notified before changing occurs and after.After I can handle using
SelectedIndexChanged event.Is there anyway to know which one is selected
item before this event.?One thing is I can have a variable to hold the
index in my application.
I'm looking exactly like TreeView events(which fires events before
expanding and after expanding the nodes).
Thanks in advance...
Regards
Krishna