Add text in c# forms WPF -
this question has answer here:
- c# put string textbox 3 answers
i want wpf project in c# , want in mainwindow interface add textbox. use toolbox add textbox field , view code found following function:
private void textbox_textchanged(object sender, textchangedeventargs e) { }
how can change default value of textbox? thing generated when add textbox function. variable responsible text? edit: trying modify wpf application provided kinect sdk. seems not straight-forward. when tried right click on textbox cant see properties option. inside mainwindow.xaml.cs there line property of textbox:
<textbox horizontalalignment="left" height="23" margin="540,3,0,0" textwrapping="wrap" text="0" verticalalignment="top" width="120" textchanged="textbox_textchanged" grid.columnspan="3"/>
however cant find name of textbox anywhere.
if select textbox , press f4 access selected item's properties (normally displayed in bottom right of screen), can set text
property in property grid. value enter used when form first created. equivalent setting text
xaml attribute on textbox
element.
in code, can in constructor using textbox1.text = "hello";
instance.
note, access textbox
in code need assign name (also via properties grid).
<textbox x:name="textbox1" text="default value goes here" horizontalalignment="left" height="23" margin="540,3,0,0" textwrapping="wrap" text="0" verticalalignment="top" width="120" textchanged="textbox_textchanged" grid.columnspan="3"/>
Comments
Post a Comment