本文介绍了两个datagridviews:从一个发送信息到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个DataGridView:DataGridView2,DataGridView3.
我在DataGridView2的名为"Column1"的列中具有复选框.
我希望能够在DataGridView2中选择多个行,然后单击和按钮,DataGridView3将仅包含复选框行.
到目前为止,这是转移"按钮中的内容:
I have two DataGridView''s: DataGridView2, DataGridView3.
I have checkboxes in DataGridView2 in a column named "Column1".
I want to be able to select multiple rows in DataGridView2 and click and button and DataGridView3 would contain only the checkboxed rows.
This is what I have so far in the "Transfer" button:
dataGridView3.Rows.Clear();
string x = string.Empty;
for (int ii = 0; ii <= dataGridView2.Rows.Count - 1; ii++)
{
DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dataGridView2.Rows[ii].Cells["Column1"];
//buttonCell.Enabled = !(Boolean)checkCell.Value;
//Displays the status value of the check box
if (dataGridView2.Rows[ii].Cells["Column1"].Value == null || dataGridView2.Rows[ii].Cells["Column1"].Value.ToString() == "" || Convert.ToBoolean(dataGridView2.Rows[ii].Cells["Column1"].Value) == false)
{ }
else
{
if (dataGridView2.Rows[ii].Cells[0].Value != null)
{ dataGridView3.Rows.Add(null,dataGridView2.Rows[ii].Cells[1].Value.ToString()); }
if (dataGridView2.Rows[ii].Cells[0].Value != null)
{ dataGridView3.Rows[dataGridView3.Rows.Count + 1].Cells[1].Value = dataGridView2.Rows[ii].Cells[2].Value.ToString(); }
//if (dataGridView2.Rows[ii].Cells[0].Value != null || dataGridView2.Rows[ii].Cells[0].Value != "")
//{ dataGridView3.Rows.Add(dataGridView2.Rows[ii].Cells[0].Value.ToString()); }
//dataGridView3.Rows[ii].Cells[3].Value = dataGridView2.Rows[ii].Cells[3].Value.ToString();
}
推荐答案
这篇关于两个datagridviews:从一个发送信息到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!