////set columns width
//this.dgTankView.Columns["MaterialCategory"].Width = 80;
//this.dgTankView.Columns["Material"].Width = 240;
//this.dgTankView.Columns["TankName"].Width = 100;
//this.dgTankView.Columns["Area"].Width = 80;
//this.dgTankView.Columns["MaxLevel"].Width = 100;
//this.dgTankView.Columns["MinLevel"].Width = 100;
//this.dgTankView.Columns["MaxCapacity"].Width = 100;
//this.dgTankView.Columns["MinCapacity"].Width = 100;
//this.dgTankView.Columns["Type"].Width = 60;
//this.dgTankView.Columns["Status"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
this.dgTankView.AutoGenerateColumns = false;
this.dgTankView.DataSource = tankviews;
int rowCount = dgTankView.RowCount;
if (SelectedIndex < rowCount || SelectedIndex >= rowCount)
{
this.dgTankView.Rows[0].Selected = true;
}
else
{
this.dgTankView.Rows[this.SelectedIndex].Selected = true;
}
for (int i = 0; i < dgrdSelectedMaterial.RowCount; i++)
{
if (decimal.Parse(dgrdSelectedMaterial.Rows[i].Cells["ColumnSelectedMinRatio"].Value.ToString()) > decimal.Parse(dgrdSelectedMaterial.Rows[i].Cells["ColumnSelectedMaxRatio"].Value.ToString()))
{
MessageUtil.Info(string.Format(Config.MessageManager[MessageGroupHelper.FormatToName((int)MessageGroup.Client), "1959"].ToString(), dgrdSelectedMaterial.Rows[i].Cells["ColumnSelectedName"].Value.ToString()));
return false;
}
}
RowHeardersVisible=false
Selection Mode=Full row Select
ColumnHeaderDefault=alignCenter
///高
dgrdStaticTank.ColumnHeadersHeight = 40;
dgrdBlendMaterialQuality.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
宽:
dgrdBlendMaterial.AutoGenerateColumns = false;
dgrdBlendMaterial.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dgrdBlendMaterial.Columns["ColumnMaterialTankName"].Width = 80;
----------------------------------------------------------
this.dataGridView1.CurrentCell.Value; //当前处于活动状态的单元格的值
this.dataGridView1.CurrentCell.RowIndex;//当前处于活动状态的单元格所在的行
this.dataGridView1.CurrentCell.ColumnIndex;//当前处于活动状态的单元格所在的列
this.dataGridView1.Rows[5].Cells[3].Value;//位于第6行第4列的单元格的值
DataGridView[col,row].Value=obj;
ControlUtil.SetDataGridViewStyleForMasterData(dgrdBlendMaterial);
dgrdBlendMaterial.AutoGenerateColumns = false;
dgrdBlendMaterial.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dgrdBlendMaterial.Columns["ColumnMaterialName"].Width = 200;
ucPagingTank.DataBindings.Add("PageIndex", tankListModel, "PageIndex", true, DataSourceUpdateMode.Never);
-----某列的显示格式----
dgrdTank.Columns["ColumnTimeStamp"].DefaultCellStyle.Format = Config.AppConfig.DateTimeFormat;
---取得选中某列的值-----
strCurRoleID = dgrdRoleList.SelectedRows[0].Cells[0].FormattedValue.ToString();
新闻热点
疑难解答