2012-06-18 6 views
1

나는이 질문에 어떻게해야 할 지 100 % 확신하지는 않지만 최선을 다할 것입니다.Winforms DataGridView 크기 조정 문제

은 내가 TableLayoutPanel 안에있는 DataGridView가있는 PointCtrlForm 있습니다. DataGridView는 채우기로 테이블에 도킹됩니다. PointCtrlForm은 dockstyle 속성이 Fill로 설정된 MDIParent로 설정된 다른 창에 도킹됩니다. 메인 창 크기를 조정

제대로 다음뿐만 아니라 DataGridView를 크기를 조정 예상되는 PointCtrlForm을, 크기를 조정합니다. 음, 크기 조정의 "절반"이 제대로 작동합니다. 주 창을 확대하면 datagridview도 확대되지만, 주 창을 특정 지점으로 축소하면 DataGridView는 축소를 멈추고 스크롤 막대를 표시하지 않고 열을 숨 깁니다.

모든 열에 Frozen 속성이 설정되어 있지 않은지 확인하고, DataGridview와 하위 창이 올바르게 고정되어 있는지 확인하고 scrollbars 속성이 둘 다로 설정되어 있는지 확인했습니다.

편집 : AutoSizeColumnsMode도 기입한다.

여기에 Designer.cs의 내용을 게시합니다. 나는 어떤 지침을 주셔서 감사합니다.

namespace DDCUI 
{ 
    partial class PointCtrlForm 
    { 
     /// <summary> 
     /// Required designer variable. 
     /// </summary> 
     private System.ComponentModel.IContainer components = null; 

     /// <summary> 
     /// Clean up any resources being used. 
     /// </summary> 
     /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 
     protected override void Dispose(bool disposing) 
     { 
      if (disposing && (components != null)) 
      { 
       components.Dispose(); 
      } 
      base.Dispose(disposing); 
     } 

     #region Windows Form Designer generated code 

     /// <summary> 
     /// Required method for Designer support - do not modify 
     /// the contents of this method with the code editor. 
     /// </summary> 
     private void InitializeComponent() 
     { 
      this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 
      this.CmbSubDevice = new System.Windows.Forms.ComboBox(); 
      this.BtnBack = new System.Windows.Forms.Button(); 
      this.CmbMainDevice = new System.Windows.Forms.ComboBox(); 
      this.dataGridView1 = new System.Windows.Forms.DataGridView(); 
      this.BtnRefresh = new System.Windows.Forms.Button(); 
      this.label1 = new System.Windows.Forms.Label(); 
      this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
      this.PointName = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
      this.Value = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
      this.Description = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
      this.DefaultValue = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
      this.ActiveString = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
      this.InactiveString = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
      this.AlarmCondition = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
      this.tableLayoutPanel1.SuspendLayout(); 
      ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); 
      this.SuspendLayout(); 
      // 
      // tableLayoutPanel1 
      // 
      this.tableLayoutPanel1.ColumnCount = 6; 
      this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); 
      this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); 
      this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); 
      this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); 
      this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 151F)); 
      this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 88F)); 
      this.tableLayoutPanel1.Controls.Add(this.CmbSubDevice, 0, 1); 
      this.tableLayoutPanel1.Controls.Add(this.BtnBack, 0, 0); 
      this.tableLayoutPanel1.Controls.Add(this.CmbMainDevice, 0, 1); 
      this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 2); 
      this.tableLayoutPanel1.Controls.Add(this.BtnRefresh, 4, 1); 
      this.tableLayoutPanel1.Controls.Add(this.label1, 5, 1); 
      this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; 
      this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); 
      this.tableLayoutPanel1.Name = "tableLayoutPanel1"; 
      this.tableLayoutPanel1.RowCount = 3; 
      this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 67.02128F)); 
      this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 32.97872F)); 
      this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 368F)); 
      this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); 
      this.tableLayoutPanel1.Size = new System.Drawing.Size(639, 467); 
      this.tableLayoutPanel1.TabIndex = 0; 
      // 
      // CmbSubDevice 
      // 
      this.tableLayoutPanel1.SetColumnSpan(this.CmbSubDevice, 2); 
      this.CmbSubDevice.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 
      this.CmbSubDevice.Font = new System.Drawing.Font("굴림", 12F); 
      this.CmbSubDevice.FormattingEnabled = true; 
      this.CmbSubDevice.Location = new System.Drawing.Point(203, 69); 
      this.CmbSubDevice.Name = "CmbSubDevice"; 
      this.CmbSubDevice.Size = new System.Drawing.Size(194, 24); 
      this.CmbSubDevice.TabIndex = 3; 
      // 
      // BtnBack 
      // 
      this.BtnBack.Location = new System.Drawing.Point(3, 3); 
      this.BtnBack.Name = "BtnBack"; 
      this.BtnBack.Size = new System.Drawing.Size(94, 54); 
      this.BtnBack.TabIndex = 0; 
      this.BtnBack.Text = "Back"; 
      this.BtnBack.UseVisualStyleBackColor = true; 
      this.BtnBack.Click += new System.EventHandler(this.BtnBack_Click); 
      // 
      // CmbMainDevice 
      // 
      this.tableLayoutPanel1.SetColumnSpan(this.CmbMainDevice, 2); 
      this.CmbMainDevice.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 
      this.CmbMainDevice.Font = new System.Drawing.Font("굴림", 12F); 
      this.CmbMainDevice.FormattingEnabled = true; 
      this.CmbMainDevice.Items.AddRange(new object[] { 
      "I/O", 
      "VIRTUAL", 
      "SAC", 
      "MODBUS", 
      "NATIONAL", 
      "TOSHIBA", 
      "SCHEDULE", 
      "SYSTEM ALARM", 
      "LOGIC", 
      "GROUP"}); 
      this.CmbMainDevice.Location = new System.Drawing.Point(3, 69); 
      this.CmbMainDevice.Name = "CmbMainDevice"; 
      this.CmbMainDevice.Size = new System.Drawing.Size(194, 24); 
      this.CmbMainDevice.TabIndex = 2; 
      this.CmbMainDevice.SelectedIndexChanged += new System.EventHandler(this.CmbMainDevice_SelectedIndexChanged); 
      // 
      // dataGridView1 
      // 
      this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; 
      this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 
      this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { 
      this.ID, 
      this.PointName, 
      this.Value, 
      this.Description, 
      this.DefaultValue, 
      this.ActiveString, 
      this.InactiveString, 
      this.AlarmCondition}); 
      this.tableLayoutPanel1.SetColumnSpan(this.dataGridView1, 6); 
      this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; 
      this.dataGridView1.Location = new System.Drawing.Point(3, 101); 
      this.dataGridView1.Name = "dataGridView1"; 
      this.dataGridView1.RowTemplate.Height = 23; 
      this.dataGridView1.Size = new System.Drawing.Size(633, 363); 
      this.dataGridView1.TabIndex = 5; 
      // 
      // BtnRefresh 
      // 
      this.BtnRefresh.Location = new System.Drawing.Point(403, 69); 
      this.BtnRefresh.Name = "BtnRefresh"; 
      this.BtnRefresh.Size = new System.Drawing.Size(94, 26); 
      this.BtnRefresh.TabIndex = 6; 
      this.BtnRefresh.Text = "Refresh"; 
      this.BtnRefresh.UseVisualStyleBackColor = true; 
      // 
      // label1 
      // 
      this.label1.AutoSize = true; 
      this.label1.Dock = System.Windows.Forms.DockStyle.Fill; 
      this.label1.Font = new System.Drawing.Font("굴림", 12F); 
      this.label1.Location = new System.Drawing.Point(554, 66); 
      this.label1.Name = "label1"; 
      this.label1.Size = new System.Drawing.Size(82, 32); 
      this.label1.TabIndex = 7; 
      this.label1.Text = "XXX 개"; 
      this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 
      // 
      // ID 
      // 
      this.ID.FillWeight = 70F; 
      this.ID.HeaderText = "ID"; 
      this.ID.Name = "ID"; 
      // 
      // PointName 
      // 
      this.PointName.FillWeight = 70F; 
      this.PointName.HeaderText = "이름"; 
      this.PointName.Name = "PointName"; 
      // 
      // Value 
      // 
      this.Value.FillWeight = 70F; 
      this.Value.HeaderText = "값"; 
      this.Value.Name = "Value"; 
      // 
      // Description 
      // 
      this.Description.FillWeight = 70F; 
      this.Description.HeaderText = "설명"; 
      this.Description.Name = "Description"; 
      // 
      // DefaultValue 
      // 
      this.DefaultValue.FillWeight = 70F; 
      this.DefaultValue.HeaderText = "초기값"; 
      this.DefaultValue.Name = "DefaultValue"; 
      // 
      // ActiveString 
      // 
      this.ActiveString.HeaderText = "Active문자열"; 
      this.ActiveString.Name = "ActiveString"; 
      // 
      // InactiveString 
      // 
      this.InactiveString.HeaderText = "InActive문자열"; 
      this.InactiveString.Name = "InactiveString"; 
      // 
      // AlarmCondition 
      // 
      this.AlarmCondition.HeaderText = "알람조건"; 
      this.AlarmCondition.Name = "AlarmCondition"; 
      // 
      // PointCtrlForm 
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); 
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
      this.ClientSize = new System.Drawing.Size(639, 467); 
      this.Controls.Add(this.tableLayoutPanel1); 
      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; 
      this.Name = "PointCtrlForm"; 
      this.Text = "LG-DDC"; 
      this.tableLayoutPanel1.ResumeLayout(false); 
      this.tableLayoutPanel1.PerformLayout(); 
      ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); 
      this.ResumeLayout(false); 

     } 

     #endregion 

     private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; 
     private System.Windows.Forms.Button BtnBack; 
     private System.Windows.Forms.ComboBox CmbMainDevice; 
     private System.Windows.Forms.ComboBox CmbSubDevice; 
     private System.Windows.Forms.DataGridView dataGridView1; 
     private System.Windows.Forms.Button BtnRefresh; 
     private System.Windows.Forms.Label label1; 
     private System.Windows.Forms.DataGridViewTextBoxColumn ID; 
     private System.Windows.Forms.DataGridViewTextBoxColumn PointName; 
     private System.Windows.Forms.DataGridViewTextBoxColumn Value; 
     private System.Windows.Forms.DataGridViewTextBoxColumn Description; 
     private System.Windows.Forms.DataGridViewTextBoxColumn DefaultValue; 
     private System.Windows.Forms.DataGridViewTextBoxColumn ActiveString; 
     private System.Windows.Forms.DataGridViewTextBoxColumn InactiveString; 
     private System.Windows.Forms.DataGridViewTextBoxColumn AlarmCondition; 

    } 
} 
+0

시도'this.AutoSizeMode = AutoSizeMode.GrowAndShrink,'MDI 자식의 Form_Load한다. 한 번만 확인하십시오. 나는 창문에 아주 좋은 명령을 가지고 있지 않다. – JayOnDotNet

+0

내가 그것을 시도했을 때, 그것은 (DataGridView를 포함하는) 자식 폼의 모든 것을 크기가 바뀔 때 사라진다. – l46kok

답변

1

해결책을 찾았습니다. 간단합니다.

DGV위한 행 및 열 크기 설정해야 도킹 위해서는 "절대"없음 "(상대) 비율"정상적으로 작동한다.

당신은 DGV의 셀 중 하나를 마우스 오른쪽 버튼으로 클릭하여 크기를 편집하고 편집 행/열 속성을 클릭 할 수 있습니다.

+0

내가 바뀌고있는 설정이 보이지 않습니까? –