Rob,
| is this possible? -- I recall seeing how this can be done, but can't
| remember where nor how .
As I stated NO!
At least no direct ways that I know of.
How many places are you setting SelectedIndex directly?
In those places I would consider setting a flag that the event handler
checks to see if you are setting it directly.
Private m_inSetSelectedIndex As Boolean
Public Sub SetSelectedIndex(value As Integer)
m_inSetSelectedIndex = True
Try
SomeControl.SelectedIndex = value
Finally
m_inSetSelectedIndex = False
End Try
End If
Private Sub SomeControl_SelectedIndexChanged(...) Handles...
If m_inSetSelectedIndex Then Exit Sub
...
End Sub
Depending on the "real" requirements on setting SelectedIndex, I would
consider encapsulating the control in a user control & offer an improved
SelectedIndexChanged that has a Reason parameter on it.
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net [quoted text, click to view] "Rob R. Ainscough" <robains@pacbell.net> wrote in message
news:u863OzmAGHA.504@TK2MSFTNGP12.phx.gbl...
| ListBox
|
| I need a way to determine if an event triggered by my source code or if it
| was triggered by some user action.
|
| is this possible? -- I recall seeing how this can be done, but can't
| remember where nor how .
|
| Rob
|
| "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@tsbradley.net> wrote in
| message news:uj3OuumAGHA.532@TK2MSFTNGP15.phx.gbl...
| > Rob,
| > There are at least 9 base types that have a SelectedIndexChanged event
in
| > .NET, which type are you referring to?
| >
| > | Is there a way for me to look at the Sender or e (System.EventArgs) to
| > | determine the source of the event. Trying to figure out if an event
was
| > | triggered by user interaction or via my code (i.e. SelectedIndex = 2).
| > Generally No, unless the e parameter itself specifically supports it.
For
| > example CloseReason on the System.Windows.Forms.FormClosedEventArgs
type.
| >
| >
| > The "sender" parameter identifies the control and/or object that is
| > sending
| > the event, useful when you have a single event handler handling the same
| > event from multiple controls and/or objects. For example all the Change
| > events on your form are handled by a single ControlChanged handler that
| > sets
| > a dirty flag.
| >
| > The "e" parameter carries "additional info", when its a type that
derives
| > from System.EventArgs. System.EventArgs itself does not carry any info,
| > its
| > common practice to send the same object EventArgs.Empty, for
| > System.EventArgs itself. To actually carry "additional info" designers
| > need
| > to inherit from System.EventArgs & add any additional info that may be
| > needed, such as System.Windows.Forms.MouseEventArgs which carries the X,
| > Y,
| > Location, Delta, Clicks, and Button information on a mouse event.
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > .NET Application Architect, Enthusiast, & Evangelist
| > T.S. Bradley -
http://www.tsbradley.net | >
| >
[quoted text, click to view] | > "Rob R. Ainscough" <robains@pacbell.net> wrote in message
| > news:eUwSqjmAGHA.3976@TK2MSFTNGP09.phx.gbl...
| > | Is there a way for me to look at the Sender or e (System.EventArgs) to
| > | determine the source of the event. Trying to figure out if an event
was
| > | triggered by user interaction or via my code (i.e. SelectedIndex = 2).
| > |
| > | thanks, Rob.
| > |
| > |
| >
| >
|
|