private void InitUI() { // 不开启分页模式 panelInfo.SuspendLayout(); m_dgvInfo = new CExDataGridView() { BPartionPageEnable = false }; m_dgvInfo.Header = new string[] { CN_DataTime, CN_InfoDetail, CN_InfoID }; m_dgvInfo.HideColomns = new int[] { 2 }; // 隐藏ID列 m_dgvInfo.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; //m_dgvInfo.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; //m_dgvInfo.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; m_dgvInfo.Dock = DockStyle.Fill; m_dgvInfo.AutoSize = false; //m_dataGridView.ReadOnly = true; //只读 m_dgvInfo.AllowUserToResizeRows = false; m_dgvInfo.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; m_dgvInfo.RowHeadersWidth = 50; m_dgvInfo.ColumnHeadersHeight = 25; m_dgvInfo.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0); m_dgvInfo.AllowUserToAddRows = false; m_dgvInfo.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //整行选中 this.m_dgvInfo.SizeChanged += (s, e) => { m_dgvInfo.Columns[0].Width = 130; }; panelInfo.Controls.Add(m_dgvInfo); panelInfo.ResumeLayout(false); btnDelete.Enabled = false; //默认不可用 // 设置日期 dtp_StartTime.Format = DateTimePickerFormat.Custom; dtp_EndTime.Format = DateTimePickerFormat.Custom; dtp_StartTime.CustomFormat = "yyyy-MM-dd HH:mm"; dtp_EndTime.CustomFormat = "yyyy-MM-dd HH:mm"; TimeSpan span = new TimeSpan(1, 0, 0, 0); dtp_StartTime.Value = DateTime.Now.Subtract(span); dtp_EndTime.Value = DateTime.Now; }
public void InitDgv() { this.SuspendLayout(); // 初始化用户信息 m_dgvUserInfo = new CExDataGridView() { BPartionPageEnable = false }; m_dgvUserInfo.Header = new string[] { "kjl", "asdfasdf" }; m_dgvUserInfo.AllowUserToAddRows = false; m_dgvUserInfo.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; m_dgvUserInfo.Dock = DockStyle.Fill; m_dgvUserInfo.AllowUserToResizeRows = false; m_dgvUserInfo.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; m_dgvUserInfo.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); m_dgvUserInfo.RowHeadersWidth = 50; m_dgvUserInfo.ColumnHeadersHeight = 25; m_dgvUserInfo.ColumnHeadersVisible = false;//隐藏表头 m_dgvUserInfo.RowHeadersVisible = false; m_dgvUserInfo.ScrollBars = ScrollBars.None; panelUserInfo.Controls.Add(m_dgvUserInfo); // 初始化状态信息 m_dgvStatusInfo = new CExDataGridView() { BPartionPageEnable = false }; m_dgvStatusInfo.Header = new string[] { "kjl", "afdasdfaf" }; m_dgvStatusInfo.AllowUserToAddRows = false; m_dgvStatusInfo.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; m_dgvStatusInfo.Dock = DockStyle.Fill; m_dgvStatusInfo.AllowUserToResizeRows = false; m_dgvStatusInfo.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; m_dgvStatusInfo.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); m_dgvStatusInfo.RowHeadersWidth = 50; m_dgvStatusInfo.ColumnHeadersVisible = false;//隐藏表头 m_dgvStatusInfo.RowHeadersVisible = false; m_dgvStatusInfo.ColumnHeadersHeight = 25; m_dgvStatusInfo.ScrollBars = ScrollBars.None; panelStatusInfo.Controls.Add(m_dgvStatusInfo); this.ResumeLayout(false); }