mr2samawi
mr2samawi

Reputation: 55

Get Control Path In project

I have button in my form it name is btnAdd I want to get full path of this button in my project like this

MyAppName.namespace.MyFormName.btnAdd

Upvotes: 1

Views: 179

Answers (1)

mm8
mm8

Reputation: 169390

btnAdd.GetType().FullName will get you the fully qualified name of the type of btnAdd.

If you want the name of the variable along with the fully qualified name of the form in which it is defined, you could do something like this:

string name = this.GetType().FullName + "." + nameof(btnAdd);

...where this refers to the form and can be replace by any other type such as for example typeof(Form1).

Upvotes: 1

Related Questions