c# - Edit a button by its given name -


i generating x amount of buttons , give of them unique name.

after generated, want edit 1 of them without regenerating them wondering if component name?

i using winforms

you can use controls property of form (or container control on form). linq can select buttons , find first button required name:

var button1 = controls.oftype<button>().firstordefault(b => b.name == "button1"); 

or if want search child controls recursively

 var button1 = controls.find("button1", true)                        .oftype<button>()                        .firstordefault(); 

without linq can use method find(string key, bool searchallchildren) of controlcollection:

control[] controls = controls.find("button1", true); if (controls.length > 0) {     button button1 = controls[0] button; } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -