I'm trying to write a code. there are a lot of checkboxes for example checkbox1 checkbox2 checkbox3 .etc , until checkbox is checked I have some text in word table rows if checkbox is not checked I want to remove the row where is the text written,
I managed to make it for separete checkboxes, but when I want 2 checkboxes or 3checkboxes simultaniously unchecked table row numbers are changing and overall I can't make it. I want to make a loop with checkboxes together but couldn't do it because of dynamic table if any ideas I will appreciate
thank you very much,
- Code: Select all
var vizireba = GetTable(document, "vizireba");
var vizireba1 = GetTable(document, "vizireba1");
// 1
if (checkBox39.Checked == false)
{
vizireba.Rows.RemoveAt(2);
vizireba1.Rows.RemoveAt(1);
}
// 2
if (checkBox46.Checked == false)
{
vizireba.Rows.RemoveAt(1);
vizireba1.Rows.RemoveAt(0);
}
//3
if (checkBox45.Checked == false)
{
vizireba.Rows.RemoveAt(3);
vizireba1.Rows.RemoveAt(2);
}
// 4
if (checkBox34.Checked == false)
{
vizireba.Rows.RemoveAt(4);
vizireba1.Rows.RemoveAt(3);
}
//5
if (checkBox43.Checked == false)
{
vizireba.Rows.RemoveAt(5);
vizireba1.Rows.RemoveAt(4);
}
I tried to combine 2 chekboxes (then 3 checkboxes) toghether with && the first one is working but second one only removes the first text from the table
- Code: Select all
if (checkBox46.Checked == false && checkBox39.Checked == false)
{
vizireba.Rows.RemoveAt(1);
vizireba.Rows.RemoveAt(1);
vizireba1.Rows.RemoveAt(0);
vizireba1.Rows.RemoveAt(0);
}
else if (checkBox39.Checked == false && checkBox46.Checked != false)
{
vizireba.Rows.RemoveAt(2);
vizireba1.Rows.RemoveAt(1);
}
else if (checkBox46.Checked == false && checkBox39.Checked != false)
{
vizireba.Rows.RemoveAt(1);
vizireba1.Rows.RemoveAt(0);
}
//this is not working
else if (checkBox46.Checked == false && checkBox45.Checked == false && checkBox39.Checked != false)
{
vizireba.Rows.RemoveAt(1);
vizireba.Rows.RemoveAt(2);
vizireba1.Rows.RemoveAt(0);
vizireba1.Rows.RemoveAt(1);