我想DataGridView只显示数据(只读),用户不能直接通过 datagridview 输入数据,而是通过DataSource和DataMember。为了防止用户输入数据,我确实设置了:
m_dView.AllowUserToAddRows = false;
为什么设置后DataGridView自动滚动不起作用?
m_dView.DataSource = ds;
m_dView.DataMember = dm;
m_dView.AutoGenerateColumns = true;
m_dView.MultiSelect = false;
m_dView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
m_dView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
m_dView.ReadOnly = true;
m_dView.AllowUserToAddRows = false;
m_dView.AllowUserToDeleteRows = false;
m_dView.AllowUserToOrderColumns = false;
m_dView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
m_dView.AllowUserToResizeColumns = false;
m_dView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
m_dView.AllowUserToResizeRows = false;
m_dView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
// auto scroll only worked only when m_dView.AllowUserToAddRows = true;
if (m_dView.Rows.Count > 0) {
m_dView.CurrentCell = m_dView.Rows[m_dView.Rows.Count - 1].Cells[0];
}