VMI,
If by control name, you mean the value of the Name property on the
control, then yes, it is, you just have to cast the sender parameter to a
type of Control, and then access the Name property.
However, this does not have to correspond to the name of the field or
variable that references the control. For dynamically created controls, the
name will not correspond to any field/variable you have. If you used the
designer to lay out the control, then it should have the same name as the
field it is assigned to in your containing class.
In general, you can not get the name of a variable/field that is
referencing a control (since multiple fields/variables can reference the
same control, and you wouldn't know what to do with the names of the
variables at that point, since the variables/fields could concievably have
the same name).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"VMI" <vo******@yahoo.comwrote in message
news:uD**************@TK2MSFTNGP06.phx.gbl...
In my Windows Form, is it possible to get the control name through object
sender in an event handler? For example, in private void
dataGridView_zip_KeyPress(object sender, KeyPressEventArgs e), how can I
know that the sender is "dataGridView_zip" ?
Thanks.
VS2005 2.0