有哪位知道Winform中 datagridview多选是怎么实现的?效果如下图:
求指点

解决方案 »

  1.   

    可以在单元格绑定一个可以多选的控件http://hi.baidu.com/wangcaidpj219x/blog/item/44d6a730bf923514ebc4af89.html
      

  2.   

    ListBox
    属性MultiSelect为true。
      

  3.   

    你是要多选datagridview的行还是listbox的行,datagridview多先加一列复选框列datagridCheckBoxcolumns,绑定就可以实现多选,listbox多选如二楼所述
      

  4.   

     private void dgvSetWorkGroup_Click(object sender, EventArgs e)
            {
                if (dgvSetWorkGroup.CurrentCell.ColumnIndex==4)
                {
                    Rectangle rect = dgvSetWorkGroup.GetCellDisplayRectangle(dgvSetWorkGroup.CurrentCell.ColumnIndex, dgvSetWorkGroup.CurrentCell.RowIndex, false);
                    ListBox lb = new ListBox();
                    lb.FormattingEnabled = true;
                    lb.ItemHeight = 12;
                    lb.Location = new Point(200, 40);
                    lb.Name = "listBox1";
                    //lb.Location= new Point
                    lb.Size = new System.Drawing.Size(220, 88);
                    lb.TabIndex = 1;
                    lb.DataSource = ScanList;
                    lb.DisplayMember = "MachineId";
                    lb.ValueMember = "MachineId";
                    lb.SelectionMode = SelectionMode.MultiSimple;
                    
                   lb.Left = rect.Left;
                   lb.Top = rect.Top;
                   lb.Width = rect.Width;
                   lb.Visible = true;
                   dgvSetWorkGroup.Controls.Add(lb);
                   lb.MouseLeave += new EventHandler(ListLeaveClick);
                }
            } private void ListLeaveClick(object sender, EventArgs e)
            {
                ListBox lb = (ListBox)sender;
                string ListBoxValue=null;
                for (int i = 0; i < lb.SelectedItems.Count; i++)
                {
                    ListBoxValue += ((System.Data.DataRowView)(lb.SelectedItems[i]))[1] + ";";
                }
                dgvSetWorkGroup.CurrentRow.Cells[4].Value = ListBoxValue;
                lb.Visible = false;
            }
    给各位分享下