0
    string items;
    string total;

    private void checkedListBox1_SelectedValueChanged(object sender, EventArgs e)
    {

        foreach (string index in checkedListBox1.CheckedItems)
        {
            for (int cnt = 0; cnt < checkedListBox1.Items.Count; cnt++)
                // total_items.(getdata.Items[index].ToString());
                total = index.ToString();     
        }
        dataGridView1.Columns.Add("Items", "Choosed Items");
        dataGridView1.Rows.Add(total);
        dataGridView1.ClearSelection();
    }
4

1 回答 1

1

我认为您没有任何其他变体可以向 datagridView 添加行。

private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{  
   if(listBox1.SelectedIndex != -1)  {         
       // Get the currently selected item in the ListBox.
       total = listBox1.SelectedItem.ToString();
       dataGridView1.Rows.Add(new object[] {total});
       listbox1.ClearSelected();
   }
}

如果选中,其他变体也许您可以使用绑定和过滤器值。

于 2013-10-10T06:06:39.567 回答