Best Way To Access controls of one from from another c# | Add data to control form another form

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome to my channel today in this video tutorial we are going to learn about accessing the controls of one form from another form or transferring the control of one form to another form so let's start so i have created this project in which i have this form one so i'll quickly create another form here so i'll right click on this add and new item and i will name this form 2 which is already so i'll add this now it is added so i'll resize this a bit i'll make this small now it looks okay i'll go to form one and i'll go to its design designer and now i'll drag in some controls here so i'll drag in a button and then i will drag in our text box so i'll search here this one i'll increase its size and i'll drag another another button so with this button i'll show the new form i'll go here to the properties and i'll change the text and the text will be show second form and now i'll click here and i'll expand it a bit so that all the text is visible now i'll double click on this to create this click event and now here i'll use form2 form2 i'll use form two equals new form two and i'll put semicolon here and form two dot show and now i'll put semicolon here now i'll create an instance of this class here so public static form one [Music] form one instance semicolon and now here i'll use a form one one instance equals this semicolon now i will go to form two this is from 1 and i'll go to form 2 and here i'll go to toolbox and add in a button and a label now on this button i'll take change the text to change the text box on form one now i'll expand it a bit so that all it takes is visible and take it to the center now double click on this and here i'll uh i access the form one instance so form one dot form one instance dot uh text box one but we can't access it here because we have to create a text box public textbox t [Music] tbx semicolon and now i'll use tbx equals text box one semicolon now we can access it in form two so i'll go to design and double click on this to go to button so i'll use from one instance dot tbx dot text equal to hello from form to i'll put semicolon here and now if i run this now the application is running so if i click on this form 2 will be shown and now if i drag this form to a side to this side and now if i click on this button now you can see that the text is added into this text box now i want to change the this label with this button click so for that uh i will close this this as well and i'll go to form2 and i'll go to form2.cs and here i'll create an instance of form2 so i'll use public static um form2 and uh instance semicolon and now here we will use instance equal to this semicolon now we have to create create label here label lbl semicolon okay now here we will use lbl equals label one now this uh this is showing an error if you hover over it so it is saying cannot implicitly convert window form app.form22 because we have named this uh form uh one so this is form two and now i'll put semicolon here so now we are good to go so i'll go to form one design and here i will change the text on this button to change label on form two and now i'll expand this button a bit i'll double click on this and now here we will use textbook form2 to dot um instance dot lbl dot text equals to form text box one dot text i'll put semicolon here and now if i run this application now the application is running if i uh enter something here hello form form one and now if i uh first show this and now i drag this to a side here and now if i click on this button now you can see hello from from one this label is changed and now if i click on this button now you can see hello from from to this text is chain so that's all for today i hope you like the video if you like the video please like subscribe and comment thank you
Info
Channel: Programming Guru
Views: 272
Rating: undefined out of 5
Keywords: Programming Guru, how to access another windows form control, modify data of another form, how to access forms contorls form another form, change controls from another form c#, modify text in windows form from another form vb.net, Best Way To Access controls of one from from another c#, Add data to control form another form, Best way to access a control on another form in Windows Forms, How to access a form control for another form, Fully access a control from another Form
Id: 1vbAcBNzFcE
Channel Id: undefined
Length: 9min 32sec (572 seconds)
Published: Mon Oct 25 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.