如何将excel单元格值显示到组合框中 [英] how to display an excel cell value into a combobox

查看:366
本文介绍了如何将excel单元格值显示到组合框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个文本框中显示一个excel单元格值但是在显示一个excel单元格值到组合框中时出现一些错误如何获取此

i display an excel cell value into a textbox but get some error in display an excel cell value into a combobox how to get this

推荐答案

你不能如果项目不在Combobox中,则直接将文本绑定到ComboBox

使用

comboBox1.Items.Add(dt.Rows [1] [Value]。ToString ());

它会将值添加到Combobox然后你选择它

comboBox1.Text = dt.Rows [1] [Value]。ToString( );如果More More One Items Available或combox1.SelectedIndex = 0;如果只有一个项目可用



comboBox1.Items.Insert(0,dt.Rows [1] [Value]。ToString());

这里的第一个参数是位置

通过使用这个你可以在一个定义的位置插入一个新项目然后你可以选择它

comboBox1.SelectedIndex =位置;这里它将是0;
You can't Directly Bind a Text to ComboBox if the Item is not in Combobox so
Use
comboBox1.Items.Add(dt.Rows[1]["Value"].ToString());
It will Add the Value to Combobox Then You Select it By
comboBox1.Text=dt.Rows[1]["Value"].ToString(); If More then One Items Available or combox1.SelectedIndex=0; If only one Item is Available
or
comboBox1.Items.Insert(0,dt.Rows[1]["Value"].ToString());
Here First Parameter is Position
By Using this You can Insert a New Item at a Defined Position and Then You can Select It By
comboBox1.SelectedIndex=position; Here it will be 0;


这篇关于如何将excel单元格值显示到组合框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆