c#的小问题
问题是这样的:我在窗口想定义一个按钮动态显示的datagridview。无意间遇见两种情况,在InitializeComponent()中写到[code=csharp]t...
问题是这样的:
我在窗口想定义一个按钮动态显示的datagridview。无意间遇见两种情况,在InitializeComponent()中写到
[code=csharp]
this.dataGridView1 = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(130, 83);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(676, 384);
this.dataGridView1.TabIndex = 0;
//本来这里编译器器还提供了一个 this.control.add(this.datagridview); 但是我发现这个东西删了之后效果跟没删一样
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();[/code]
然后我拉了一个button,在单击事件中按着上面那样写。
[code=csharp]this.dataGridView1 = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(130, 83);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(676, 384);
this.dataGridView1.TabIndex = 0;
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();[/code]
然后我发现单击的时候并不会显示控件出来(我把InitializeComponent()中那段代码删掉了)。必须要添加this.control.add(this.datagridview); 这段才能正常显示。 这是怎么回事? 展开
我在窗口想定义一个按钮动态显示的datagridview。无意间遇见两种情况,在InitializeComponent()中写到
[code=csharp]
this.dataGridView1 = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(130, 83);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(676, 384);
this.dataGridView1.TabIndex = 0;
//本来这里编译器器还提供了一个 this.control.add(this.datagridview); 但是我发现这个东西删了之后效果跟没删一样
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();[/code]
然后我拉了一个button,在单击事件中按着上面那样写。
[code=csharp]this.dataGridView1 = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(130, 83);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(676, 384);
this.dataGridView1.TabIndex = 0;
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();[/code]
然后我发现单击的时候并不会显示控件出来(我把InitializeComponent()中那段代码删掉了)。必须要添加this.control.add(this.datagridview); 这段才能正常显示。 这是怎么回事? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询