winforms - How to display text in a TextBox on a Windows Form C# -


there several answers online question none of them have answered question. have windows form has list of details of user, of data can edited while cannot. want 'getusername()' (which returns username) , display in textbox

    // display student details form     public void displaystudent()     {         studentdetails sd = new studentdetails();         sd.showdialog();     } 

the above creates new form contains several labels , textboxes, when created (and displayed), textboxes on form should populate contain student information (such username, name, address etc)

    private void displayusername_textchanged(object sender, eventargs e)     {         displayusername.text = displayusername.text = s.getusername();     } 

s student object

the above code, wish take username student object , display in textbox user see , possibly edit.

try code note specify text displayusername box given after i've created object , x merely whatever have ensuring instance has data set use rather being blank continue bug.

// display student details form public void displaystudent() {     studentdetails sd = new studentdetails();     sd.getdata(x);     displayusername.text = sd.getusername();     sd.showdialog(); } 

the textchanged call you'd use after user has changed value of text box , part of processing form rather initializing it, in experience.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -