
进入Button的click事件,
若你想要的值是字符型的就:string temp=textboxtext
若你想要的是数值型的就:int temp=ConvertToInt32(textboxtext)
1
通过
textbox
的属性进行获取;以下假设
textbox
的
name
是
textbox
2
winform
是
text
属性,
string
str
=
textboxtext;
就是窗体 textbox
的值。
3
wpf
是
content
属性,
string
str
=
textboxcontent;
就是窗体 textbox
的值。
//sql语句string sql = stringFormat("SELECT text FROM Test WHERE ID = {0})", 1);
//数据库名为Tempmdb,表为Test,包含2个字段:ID 和 text
string DbConnectionString = "Data Source=Computer-PC;User ID=sa;Password=123456;Initial Catalog=Temp;Pooling=true";
SqlConnection con = new SqlConnection(DbConnectionString);
SqlCommand cmd = new SqlCommand(sql, con);
cmdCommandType = CommandTypeText;
SqlDataReader myReader;
conOpen();
myReader = cmdExecuteReader();
textBox1Text = myReader["text"]ToString();
MessageBoxShow("完成!", "系统提示", MessageBoxButtonsOK, MessageBoxIconInformation);
cmdCancel();
myReaderClose();
以上就是关于如何调用textbox里面的数值全部的内容,包括:如何调用textbox里面的数值、C#窗体中多个textbox文件中值的读取 *** 作、C# winform 如何把数据库里面的内容赋值给textbox等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)