使用 gridcontrol devexpress 中的复选框删除选定数据?

Delete Selected data using checkbox in gridcontrol devexpress?

如何使用 devexpress 中的复选框删除选定的数据...我使用 VS2013 和 devexpress 14.2。在我的 属性 gridView1 中,我设置了

选项选择:

MultiSelect = true
MultiSelectMode = CheckBoxRowSelect
ResetSelectionClickOutsideCheckbox = true

这里是我的删除方法的代码:

private void DeleteContact()
        {
            try
            {
                if (gridView1.DataRowCount == 0)
                {
                    MessageBox.Show("DATA MASIH KOSONG");
                }
                else
                {
                    if (MessageBox.Show("Apakah Kamu ingin menghapus data ini?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                    {
                        //membuat koneksi_manual
                        if (koneksi_manual.con.State == ConnectionState.Open)
                        {
                            koneksi_manual.con.Close();
                        }
                        koneksi_manual.con.Open();

                        //koneksi_manual.con.Open();
                        OracleCommand cmd = new OracleCommand();

                        // Get your currently selected grid row
                        var rowHandle = gridView1.FocusedRowHandle;

                        // Get the value for the given column - convert to the type you're expecting
                        var obj = gridView1.GetRowCellValue(rowHandle, "NAMA");

                        //koneksi_manual.con.Open();
                        cmd.CommandText = "DELETE FROM CONTACT WHERE NAMA = '" + obj + "'";
                        cmd.Connection = koneksi_manual.con;
                        cmd.ExecuteNonQuery();
                        //koneksi_manual.con.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                // Memunculkan pesan error
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

正是

var obj = gridView1.GetRowCellValue(rowHandle, "NAMA");

这只是从 gridView1 中获取值来删除数据。我不知道如何删除 gridcontrol 中使用的复选框。

有人可以帮助或建议我吗? 谢谢

而不是 gridView1.FocusedRowHandle;,使用 gridView1.GetSelectedRows;,其中 returns 表示所选行句柄的整数值数组。

foreach(var rowHandle in gridView1.GetSelectedRows()){

 ...

}