关于FullRowSelected属性

时间:2018-12-20 08:14:57

标签: c#

Datagridview的FullRowSelect功能在此代码起作用后不起作用。正在选择单个单元格。

private void CaO() 
{
    System.Data.DataTable tbl = new System.Data.DataTable();

    new OleDbDataAdapter("SELECT * FROM [Sayfa1$]", 
        @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\ikinciexcel.xlsx; Extended Properties='Excel 12.0 xml;HDR=YES;'").Fill(tbl);
    System.Data.DataTable dtCloned = tbl.Clone();
    dtCloned.Columns[1].DataType = typeof(float);
    foreach (DataRow row in tbl.Rows)
    {
        dtCloned.ImportRow(row);
    }
    var f = new Form();
    var dgv = new DataGridView { DataSource = dtCloned, Dock = DockStyle.Fill };
    dtCloned.DefaultView.RowFilter = "CaO >= 1 and CaO <= 11";
    dataGridView2.Controls.Add(dgv);           
}

2 个答案:

答案 0 :(得分:0)

您需要设置SelectionMode属性

var dgv = new DataGridView { 
    DataSource = dtCloned, 
    Dock = DockStyle.Fill,
    SelectionMode = DataGridViewSelectionMode.FullRowSelect;
};

答案 1 :(得分:0)

如您所说,只有selectedDatagridview。来自Datagridview

首先将multiselect选择属性true设置为code

您也可以像这样通过dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView1.MultiSelect = True; 进行操作

Datagridview

然后您只需选择所有private void selectButton_Click(object sender, EventArgs e) { dataGridView1.SelectAll(); } 之类的

import {get} from Lodash

var x=get(item,path.join("."))