将一个的datatable绑定到下拉框,指定显示某列的数据
cbx.DataSource = null; DataSet dsJH = new DataSet(); OperatePort.Operate_Block("select", 0, qkmc, "", 1, 1, "", out dsJH); if (!Common.JudgeDs(dsJH)) { cbx.DataSource = dsJH.Tables[0]; cbx.DisplayMember = "井号"; }
private void btnOpenfile_Click(object sender, EventArgs e) { OpenFileDialog odlgTxt = new OpenFileDialog(); odlgTxt.Title = "请选择文件"; odlgTxt.Filter = "文本文件(*.txt)|*.TXT"; if (odlgTxt.ShowDialog() == DialogResult.OK) { string file = odlgTxt.FileName; string str = File.ReadAllText(file, System.Text.Encoding.GetEncoding("gb2312")); txtJH.Text = str; } }
中问的逗号是两个char,用foreach遍历时,是两个,会影响前面的字符组成的字符串。英文的逗号是一个char,
string jHAll = txtJH.Text.Trim().Replace(',',','); string jing = ""; foreach (char jh in jHAll) { //if (jh != ','|jh != ',') if (jh != ',') { jing += jh.ToString(); } if (jh == ',') { }
string jHAll = txtJH.Text.Trim().Replace(',',','); string[] jhs = jHAll.Split(','); string jing = ""; foreach (string jh in jhs) { }