嗨大家好: 我正在使用Windows Forms C#来开发我的应用程序。在我的表单中,我有2个datagridview(dataGridView1和dataGridView2)。 dataGridView1是一个数据源表。在我的表中,我有PurchaseDateTime。我有用户条目的DateTimePicker。 我想通过更改dateTimePicker中的值来过滤dataGridView1,并将过滤后的数据显示到dataGridView2中。 我在网上冲了很多,但没有找到任何有用的东西。 如果你能帮我,我很感激。
Hi Guys: I am using Windows Forms C# to develop my application. In my form I have 2 datagridview ( dataGridView1 and dataGridView2) . dataGridView1 is boud to a datasource table. In my table I have PurchaseDateTime. I have DateTimePicker for the user entry. I want to filter my dataGridView1 by the change of value in my dateTimePicker and show the filtered data into dataGridView2. I surfed the webs alot, but didn''t find anything useful. I appreciate if you help me.
推荐答案在datepicker'的valuechanged事件中你可以做类似的事情 On the datepicker''s valuechanged event you can do something like this DataSet ds = ((BindingSource)(dataGridView1.DataSource)).DataSource as DataSet; DataRow[] res = ds.Tables[0].Select("date = ''" + dateTimePicker1.Value.ToShortDateString() + "''"); dataGridView2.DataSource = res;
更多推荐
如何过滤datafridview表并将其显示到另一个表中
发布评论