C# windows窗体可以';不要添加更多组件
我想构建一个有100个标签和100个文本框的表单 我所做的是:C# windows窗体可以';不要添加更多组件,c#,winforms,windows-forms-designer,C#,Winforms,Windows Forms Designer,我想构建一个有100个标签和100个文本框的表单 我所做的是: 添加新表单 使用拖放将面板添加到该窗体 将该面板的dock属性更改为fill 将AutoScroll属性更改为True 开始使用拖放添加标签和文本框 问题 我添加了40个标签和文本框,但是我不能再添加了,因为我不能垂直扩展表单和标签 注 我可以最小化面板的大小,并显示一个垂直滚动条。(也许这些信息可以帮助您帮助我)。这是我用来向表单添加未知数量控件的示例方法。诀窍是一个FlowLayoutPanel 如前所述:您不希望在页面上手动添
dock
属性更改为fillAutoScroll
属性更改为True我可以最小化面板的大小,并显示一个垂直滚动条。(也许这些信息可以帮助您帮助我)。这是我用来向表单添加未知数量控件的示例方法。诀窍是一个FlowLayoutPanel 如前所述:您不希望在页面上手动添加100个控件
private void AddMappingControls() {
HeaderFlowLayoutPanel.Controls.Clear();
MappingFlowLayoutPanel.Controls.Clear();
Label sourceHeaderLabel = new Label();
sourceHeaderLabel.Text = "Velden in Excel (bron)";
sourceHeaderLabel.Name = "BronLabel";
sourceHeaderLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
HeaderFlowLayoutPanel.Controls.Add(sourceHeaderLabel);
Label destinationHeaderLabel = new Label();
destinationHeaderLabel.Text = "Velden in Word sjabloon (bestemming)";
destinationHeaderLabel.Name = "BestemmingLabel";
destinationHeaderLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
HeaderFlowLayoutPanel.Controls.Add(destinationHeaderLabel);
foreach (string destination in this.destinationFields) {
ComboBox sourceFieldComboBox = new ComboBox();
sourceFieldComboBox.BindingContext = new System.Windows.Forms.BindingContext();
sourceFieldComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
//sourceFieldComboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
sourceFieldComboBox.Name = destination + "ComboBox";
sourceFieldComboBox.ValueMember = destination;
sourceFieldComboBox.DataSource = this.sourceFields;
sourceFieldComboBox.Width = MappingFlowLayoutPanel.Width / 2 - 20;
MappingFlowLayoutPanel.Controls.Add(sourceFieldComboBox);
Label nameLabel = new Label();
nameLabel.Text = destination;
nameLabel.Name = destination + "Label";
nameLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
MappingFlowLayoutPanel.Controls.Add(nameLabel);
}
}
这是我用来向表单添加未知数量控件的示例方法。诀窍是一个FlowLayoutPanel 如前所述:您不希望在页面上手动添加100个控件
private void AddMappingControls() {
HeaderFlowLayoutPanel.Controls.Clear();
MappingFlowLayoutPanel.Controls.Clear();
Label sourceHeaderLabel = new Label();
sourceHeaderLabel.Text = "Velden in Excel (bron)";
sourceHeaderLabel.Name = "BronLabel";
sourceHeaderLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
HeaderFlowLayoutPanel.Controls.Add(sourceHeaderLabel);
Label destinationHeaderLabel = new Label();
destinationHeaderLabel.Text = "Velden in Word sjabloon (bestemming)";
destinationHeaderLabel.Name = "BestemmingLabel";
destinationHeaderLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
HeaderFlowLayoutPanel.Controls.Add(destinationHeaderLabel);
foreach (string destination in this.destinationFields) {
ComboBox sourceFieldComboBox = new ComboBox();
sourceFieldComboBox.BindingContext = new System.Windows.Forms.BindingContext();
sourceFieldComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
//sourceFieldComboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
sourceFieldComboBox.Name = destination + "ComboBox";
sourceFieldComboBox.ValueMember = destination;
sourceFieldComboBox.DataSource = this.sourceFields;
sourceFieldComboBox.Width = MappingFlowLayoutPanel.Width / 2 - 20;
MappingFlowLayoutPanel.Controls.Add(sourceFieldComboBox);
Label nameLabel = new Label();
nameLabel.Text = destination;
nameLabel.Name = destination + "Label";
nameLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
MappingFlowLayoutPanel.Controls.Add(nameLabel);
}
}
这是我用来向表单添加未知数量控件的示例方法。诀窍是一个FlowLayoutPanel 如前所述:您不希望在页面上手动添加100个控件
private void AddMappingControls() {
HeaderFlowLayoutPanel.Controls.Clear();
MappingFlowLayoutPanel.Controls.Clear();
Label sourceHeaderLabel = new Label();
sourceHeaderLabel.Text = "Velden in Excel (bron)";
sourceHeaderLabel.Name = "BronLabel";
sourceHeaderLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
HeaderFlowLayoutPanel.Controls.Add(sourceHeaderLabel);
Label destinationHeaderLabel = new Label();
destinationHeaderLabel.Text = "Velden in Word sjabloon (bestemming)";
destinationHeaderLabel.Name = "BestemmingLabel";
destinationHeaderLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
HeaderFlowLayoutPanel.Controls.Add(destinationHeaderLabel);
foreach (string destination in this.destinationFields) {
ComboBox sourceFieldComboBox = new ComboBox();
sourceFieldComboBox.BindingContext = new System.Windows.Forms.BindingContext();
sourceFieldComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
//sourceFieldComboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
sourceFieldComboBox.Name = destination + "ComboBox";
sourceFieldComboBox.ValueMember = destination;
sourceFieldComboBox.DataSource = this.sourceFields;
sourceFieldComboBox.Width = MappingFlowLayoutPanel.Width / 2 - 20;
MappingFlowLayoutPanel.Controls.Add(sourceFieldComboBox);
Label nameLabel = new Label();
nameLabel.Text = destination;
nameLabel.Name = destination + "Label";
nameLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
MappingFlowLayoutPanel.Controls.Add(nameLabel);
}
}
这是我用来向表单添加未知数量控件的示例方法。诀窍是一个FlowLayoutPanel 如前所述:您不希望在页面上手动添加100个控件
private void AddMappingControls() {
HeaderFlowLayoutPanel.Controls.Clear();
MappingFlowLayoutPanel.Controls.Clear();
Label sourceHeaderLabel = new Label();
sourceHeaderLabel.Text = "Velden in Excel (bron)";
sourceHeaderLabel.Name = "BronLabel";
sourceHeaderLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
HeaderFlowLayoutPanel.Controls.Add(sourceHeaderLabel);
Label destinationHeaderLabel = new Label();
destinationHeaderLabel.Text = "Velden in Word sjabloon (bestemming)";
destinationHeaderLabel.Name = "BestemmingLabel";
destinationHeaderLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
HeaderFlowLayoutPanel.Controls.Add(destinationHeaderLabel);
foreach (string destination in this.destinationFields) {
ComboBox sourceFieldComboBox = new ComboBox();
sourceFieldComboBox.BindingContext = new System.Windows.Forms.BindingContext();
sourceFieldComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
//sourceFieldComboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
sourceFieldComboBox.Name = destination + "ComboBox";
sourceFieldComboBox.ValueMember = destination;
sourceFieldComboBox.DataSource = this.sourceFields;
sourceFieldComboBox.Width = MappingFlowLayoutPanel.Width / 2 - 20;
MappingFlowLayoutPanel.Controls.Add(sourceFieldComboBox);
Label nameLabel = new Label();
nameLabel.Text = destination;
nameLabel.Name = destination + "Label";
nameLabel.Width = MappingFlowLayoutPanel.Width / 2 - 20;
MappingFlowLayoutPanel.Controls.Add(nameLabel);
}
}
我的意思和MeanGreen完全一样,但他是第一个。我创建了示例解决方案:我的意思与MeanGreen完全相同,但他是第一个。我创建了示例解决方案:我的意思与MeanGreen完全相同,但他是第一个。我创建了示例解决方案:我的意思与MeanGreen完全相同,但他是第一个。我创建了示例解决方案:将父窗体的属性设置为
AutoSize
和AutoScroll
为true。然后禁用面板的停靠。通过这种方式,您可以将任何大小设置为“面板”,并滚动表单内容以添加新控件。完成面板设计后,再次将停靠设置为填充
也可以使用“属性”面板为新添加的控件设置位置。这将把控件移动到面板上的适当位置。将父窗体的属性设置为
自动调整大小
和自动滚动
为真。然后禁用面板的停靠。通过这种方式,您可以将任何大小设置为“面板”,并滚动表单内容以添加新控件。完成面板设计后,再次将停靠设置为填充
也可以使用“属性”面板为新添加的控件设置位置。这将把控件移动到面板上的适当位置。将父窗体的属性设置为
自动调整大小
和自动滚动
为真。然后禁用面板的停靠。通过这种方式,您可以将任何大小设置为“面板”,并滚动表单内容以添加新控件。完成面板设计后,再次将停靠设置为填充
也可以使用“属性”面板为新添加的控件设置位置。这将把控件移动到面板上的适当位置。将父窗体的属性设置为
自动调整大小
和自动滚动
为真。然后禁用面板的停靠。通过这种方式,您可以将任何大小设置为“面板”,并滚动表单内容以添加新控件。完成面板设计后,再次将停靠设置为填充
也可以使用“属性”面板为新添加的控件设置位置。这会将控件移动到面板上的适当位置。包含如此多文本框的数据输入窗口将需要滚动。因此,首先将面板的AutoScrollMinSize属性设置为(10001000)。您将看到滚动条出现。它们也在设计时工作,允许您滚动面板并放置控件。很可能您应该使用DataGridView btw
需要说明的是:让一个人输入100个数据项而不出错的几率非常接近于零。对于不幸的用户来说,这是一项非常令人沮丧的工作,他只需要10分钟或更长的时间就可以达到失败。创建一个用户友好的UI,该UI将数据输入作业划分为可以成功完成的小步。自动解决这个问题。包含这么多文本框的数据输入窗口需要滚动。因此,首先将面板的AutoScrollMinSize属性设置为(10001000)。您将看到滚动条出现。它们也在设计时工作,允许您滚动面板并放置控件。很可能您应该使用DataGridView btw
需要说明的是:让一个人输入100个数据项而不出错的几率非常接近于零。对于不幸的用户来说,这是一项非常令人沮丧的工作,他只需要10分钟或更长的时间就可以达到失败。创建一个用户友好的UI,该UI将数据输入作业划分为可以成功完成的小步。自动解决这个问题。包含这么多文本框的数据输入窗口需要滚动。因此,首先将面板的AutoScrollMinSize属性设置为(10001000)。您将看到滚动条出现。它们也在设计时工作,允许您滚动面板并放置控件。很可能您应该使用DataGridView btw 需要说明的是:让一个人输入100个数据项而不出错的几率非常接近于零。对于不幸的用户来说,这是一项非常令人沮丧的工作,他只需要10分钟或更长的时间就可以达到失败。创建一个用户友好的UI,该UI将数据输入作业划分为可以成功完成的小步。自动解决这个问题。A