winform 에 DataGrid 바 인 딩

4854 단어 winformDataGrid

this.dgTankView.Columns["ID"].DataPropertyName = "ID";
            this.dgTankView.Columns["TankName"].DataPropertyName = "Name";
            this.dgTankView.Columns["Area"].DataPropertyName = "Area";
            this.dgTankView.Columns["Type"].DataPropertyName = "Type";
            this.dgTankView.Columns["Status"].DataPropertyName = "Status";
            this.dgTankView.Columns["Material"].DataPropertyName = "Material";
            this.dgTankView.Columns["MaterialCategory"].DataPropertyName = "MaterialCategory";
            this.dgTankView.Columns["MaxLevel"].DataPropertyName = "MaxLevel";
            this.dgTankView.Columns["MinLevel"].DataPropertyName = "MinLevel";
            this.dgTankView.Columns["MaxCapacity"].DataPropertyName = "MaxCapacity";
            this.dgTankView.Columns["MinCapacity"].DataPropertyName = "MinCapacity";
            this.dgTankView.Columns["Code"].DataPropertyName = "Code";

            ////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();


좋은 웹페이지 즐겨찾기