C#中怎么把Combox中选中的数转换为整型数值?
我是新手,希望得到高手指点!急!!!先谢为快! --------------------编程问答--------------------Convert.ToInt32("xxx")--------------------编程问答-------------------- Convert.ToInt32("xxx") --------------------编程问答-------------------- xxx该怎么写 --------------------编程问答--------------------
string s="xx";
convert.toInt32("s") --------------------编程问答-------------------- string s="xx";
convert.toInt32("s") --------------------编程问答-------------------- Convert toint32(Combox.SelectedValue);
Convert toint32(Combox.text);
都不对!!!
--------------------编程问答-------------------- Convert.ToInt32(comboBox1.SelectedText) --------------------编程问答-------------------- 大哥些,是获取Combox中数值呀,里面填充的是数字,我想把它某个数值取出来运算,怎么用? --------------------编程问答-------------------- comboBox1.Items[].ToString(),取某项的值 --------------------编程问答--------------------
Convert.ToInt32(comboBox1.SelectedValue)--------------------编程问答-------------------- convert.toint32(combox.selectitem.tostring()),楼主试试这个 --------------------编程问答-------------------- 测试通过的代码:
或者
int.parse(comboBox1.SelectedValue)
string numStr = comboBox1.SelectedItem.ToString();--------------------编程问答-------------------- 类似12楼的答案都是正确的,谢谢大家的讨论!!! --------------------编程问答-------------------- int outint = 0;
int num = Convert.ToInt32(numStr);
int.TryParse("123",out outint);
用这个更好。 --------------------编程问答-------------------- //如果输入的不是数字键,也不是回车键、Backspace键,则取消该输入
if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar!=(char)13 && e.KeyChar!=(char)8)
{
e.Handled = true;
} --------------------编程问答-------------------- convert.toint32(combox.selectitem.tostring()) --------------------编程问答-------------------- up..Convert.ToInt32(comboBox1.SelectedValue); --------------------编程问答-------------------- convert.toint32(combox.SelectedValue.tostring()) --------------------编程问答--------------------
--------------------编程问答-------------------- 顶 --------------------编程问答-------------------- 不懂就查下网 --------------------编程问答-------------------- 人踩 --------------------编程问答-------------------- mark --------------------编程问答-------------------- int i=int.parse(comboBox1.selectedvalue.tostring()); --------------------编程问答--------------------
try
{
if(combox.SelectedValue.tostring()!="")
{
convert.toint32(combox(控件的名字).SelectedValue.tostring());
}
}
catch(Exception ex)
{
throw ex.message;
}
UP up UPup && jf --------------------编程问答-------------------- int.Parse(Combobox.SelectedItem) --------------------编程问答-------------------- 5楼....错的也抄. --------------------编程问答--------------------
嘿嘿, 对呀 --------------------编程问答--------------------
int.Parse(comboBox1.SelectedValue.toString())
补充:.NET技术 , C#