private void InitLinkDgv(DataGridView linkDgv, object param) { Int32 ctnId = (Int32)param; //初始化DataGridView的基本属性 linkDgv.Location = new Point(10, 10); linkDgv.Size = new Size(10, 10); linkDgv.Dock = DockStyle.Fill; linkDgv.RowHeadersVisible = false; linkDgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; linkDgv.AllowUserToAddRows = false; linkDgv.EditMode = DataGridViewEditMode.EditOnEnter; linkDgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //添加列 linkDgv.ColumnCount = 4; linkDgv.Columns[0].Name = _dgvColumnTitle_serialNum; linkDgv.Columns[0].ReadOnly = true; linkDgv.Columns[1].Name = _dgvColumnTitle_end1CntNum; linkDgv.Columns[1].ReadOnly = true; linkDgv.Columns[2].Name = _dgvColumnTitle_end1PosNum; linkDgv.Columns[3].Name = _dgvColumnTitle_end2PosNum; //在相应位置插入comboboxColumn:"端2槽位号" var comboColumn = new DataGridViewComboBoxColumn(); comboColumn.Name = _dgvColumnTitle_end2CntNum; comboColumn.DataSource = GetListRangeInt(0, CntNum, new List <int> { ctnId }); linkDgv.Columns.Insert(3, comboColumn); //在相应位置插入comboboxColumn:"连接类型" comboColumn = new DataGridViewComboBoxColumn(); comboColumn.Name = _dgvColumnTitle_linkType; comboColumn.DataSource = StringConvert.GetLinkType_StringList(); linkDgv.Columns.Insert(1, comboColumn); //在最后添加comboboxColumn:"带宽" comboColumn = new DataGridViewComboBoxColumn(); comboColumn.Name = _dgvColumnTitle_dataWidth; comboColumn.DataSource = StringConvert.GetLinkLanes_StringList(); linkDgv.Columns.Add(comboColumn); //最后添加一个确定按钮 var btnColumn = new DataGridViewButtonColumn(); btnColumn.Name = _dgvColumnTitle_confirm; linkDgv.Columns.Add(btnColumn); //注册事件处理函数 linkDgv.Click += new EventHandler(LinksDgv_Click); }
/// <summary> /// 初始化计算颗粒的DataGridView /// </summary> /// <param name="dgv"></param> /// <param name="param">当前计算颗粒的序号(int)</param> private void InitDataGridView(DataGridView dgv, object param) { Int32 nodeNum = (Int32)param; //初始化DataGridView的基本属性 dgv.Location = new Point(10, 10); dgv.Size = new Size(10, 10); dgv.Dock = DockStyle.Fill; dgv.RowHeadersVisible = false; dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgv.AllowUserToAddRows = false; dgv.EditMode = DataGridViewEditMode.EditOnEnter; dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //添加列 dgv.ColumnCount = 2; dgv.Columns[0].Name = _dgvColumnTitle_serialNum; dgv.Columns[0].ReadOnly = true; dgv.Columns[1].Name = _dgvColumnTitle_end1CmpNum; dgv.Columns[1].ReadOnly = true; //在相应位置插入comboboxColumn:"端2构件号" var comboColumn = new DataGridViewComboBoxColumn(); comboColumn.Name = _dgvColumnTitle_end2CmpNum; comboColumn.DataSource = GetListRangeInt(0, _nodeArray.Length, new List <int> { nodeNum }); dgv.Columns.Add(comboColumn); //在相应位置插入comboboxColumn:"连接类型" comboColumn = new DataGridViewComboBoxColumn(); comboColumn.Name = _dgvColumnTitle_linkType; comboColumn.DataSource = StringConvert.GetLinkType_StringList(); dgv.Columns.Insert(1, comboColumn); //在最后添加comboboxColumn:"带宽" comboColumn = new DataGridViewComboBoxColumn(); comboColumn.Name = _dgvColumnTitle_dataWidth; comboColumn.DataSource = StringConvert.GetLinkLanes_StringList(); dgv.Columns.Add(comboColumn); base.tabControl1.SelectedIndex = nodeNum; //最后添加一个确定按钮 var btnColumn = new DataGridViewButtonColumn(); btnColumn.Name = _dgvColumnTitle_confirm; dgv.Columns.Add(btnColumn); dgv.Click += new EventHandler(dgv_Click); }