Hi Chenbinhao,
Based on your description, I made a test with the following code and it worked fine.
So could you provide more related code to reproduce the situation.
Here is my test code:
DataTable t = new DataTable();
DataTable dt = new DataTable();
private void Form1_Load(object sender, EventArgs e)
{
t.Columns.Add(new DataColumn("Col1", typeof(bool)));
t.Columns.Add(new DataColumn("Col2", typeof(int)));
t.Columns.Add(new DataColumn("Col3", typeof(int)));
dt.Columns.Add(new DataColumn("Col1", typeof(bool)));
dt.Columns.Add(new DataColumn("Col2", typeof(int)));
dt.Columns.Add(new DataColumn("Col3", typeof(int)));
t.Rows.Add(true, 1, 1);
t.Rows.Add(false, 2, 2);
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < t.Rows.Count; i++)
{
var dr = t.Rows[i];
if ((bool)dr[0])
{
dt.ImportRow(dr);
}
}
}
The watch screen:
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentationto enable e-mail notifications if you want to receive the related email notification for this thread.