且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

根据Multilite文本框中的每一行选择Datagridview中的行

更新时间:2023-02-05 09:58:55

如果您要进行硬编码,那么我看到的唯一选择是在此处使用此代码:
http://social.msdn.microsoft.com/Forums/zh/wpf/thread/a5fd5413-f055-4b56-83af-6d6bdb1d6fe9 [
If you are going to hard code this the only option I see is to use this code here:
http://social.msdn.microsoft.com/Forums/en/wpf/thread/a5fd5413-f055-4b56-83af-6d6bdb1d6fe9[^]

The esayer thing, and fare more efficient thing is to do a search in the DataTable that you bind the DataGridView to, and you could highlight it with the code in the first link.

There is also the question on what to filter the data with, Id use either link or the build in filter function in the DataGridVeiw-


感谢您的回答!

我得到了一些东西,它接近了,但是问题是我需要写任何我想在多行文本框中使用的单行,不好…….

用一个简单的代码或一个循环或类似的东西来做是很好的.

希望有人帮忙!

下面的代码,谢谢,




Thanks for answering!

I got something, it''s close but the issue is that I''ll need to write any single line that I''d like to use in the Multiline Textbox, not good...

Would be great do it with a simple code or a loop or some like that.

Hope somebody helps!

Code Below, Thanks,




string[] lines = textBox1.Lines;


         string sql = "Select Name_Column FROM Database";


         OleDbDataAdapter da = new OleDbDataAdapter();
         da = new OleDbDataAdapter(sql, conneccionDB);
         DataSet ds = new DataSet();
         da.Fill(ds, "Database");


         DataView dtv = new DataView(ds.Tables[0], "Name_Column LIKE '%" +  lines[0] + "%' OR Name_Column LIKE '%" + lines[1] + "%'", "Name_Column", DataViewRowState.CurrentRows);

          lineIndex++;
          datagrid_catnumRef.DataSource = dtv;