我创建了一个组合框,然后在运行时使用按钮填充它.我还创建了一个按钮,比如Button1循环浏览组框并删除这些按钮.这是我的Button1代码:
Public Sub removeControls()
For Each ctrl As Control In GroupBox1.Controls
GroupBox1.Controls.Remove(ctrl)
ctrl.Dispose()
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
removeControls()
End Sub
Run Code Online (Sandbox Code Playgroud)
执行时,它只删除GroupBox1中的一些控件,而不是全部.你能解释我的代码中缺少什么使它工作吗?谢谢.
如何在表单中的GroupBox中获得圆角?属性选项卡中是否有任何选项?
我正面临WPF GroupBox的一个恼人的问题,希望有人可以帮助我.基本上问题是这样的:我在GroupBox中有一个listview,但无论我做什么,我似乎都无法使它填充GroupBox.
这是基本代码:
<GroupBox Grid.Row="2" Header="Field" Visibility="{Binding ElementName=radioUnbound, Path=IsChecked, Converter={StaticResource bool2vis}}" Margin="0" VerticalContentAlignment="Stretch">
<ListView ItemsSource="{Binding ElementName=nnf1, Path=UnboundFields}" x:Name="listUnbound" SelectionChanged="listSelectionChanged" VerticalAlignment="Stretch" >
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding name}" Margin="2"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</GroupBox>
Run Code Online (Sandbox Code Playgroud)
我尝试将列表包含在Grids,StackPanels,DockPanel等中......但无论我尝试什么,我总是总是这样:

我正在使用BDS 2006,并想知道你是否可以使用项目中存在的XPmanifest更改Group-box和radio组标题的颜色(因为它总是蓝色).
我没有找到任何帮助我解决旧问题的解决方案...是否可以通过改变颜色使它们更厚或更明显?如果是的话,一些代码会很棒......或者只是提示如何做到这一点......
我有一个groupBox名称"groupBox".我想禁用整个groupbox,包括组框的名称.我正在附上图像.我希望它能清除这种情况
<GroupBox Name="groupBox" Grid.Column="0" Grid.Row="1" Margin="2,0,0,0" Header="GroupBox" IsEnabled="False">
<Grid Margin="10,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height=".250*"/>
<RowDefinition Height=".250*"/>
</Grid.RowDefinitions>
<RadioButton Name="RadioBtn1" VerticalAlignment="Center" ToolTipService.ShowOnDisabled="True" Grid.ColumnSpan="3" Height="14.63">OP1</RadioButton>
<RadioButton Name="RadioBtn2" Grid.Row="1" VerticalAlignment="Center" ToolTipService.ShowOnDisabled="True" Grid.ColumnSpan="3" Height="14.63">OP2</RadioButton>
</Grid>
</GroupBox>
Run Code Online (Sandbox Code Playgroud)
我使用的是IsEnabled ="False"属性.但它只能处理groupBox的内容(如果我错了,请给我现在!)现在我希望圈区也应该禁用.
我想包含ScrollViewer在我的 中Groupbox,但它不起作用。我的代码是:
<GroupBox
Margin="10,10,0,0"
Grid.Row="0"
Grid.ColumnSpan="3"
Height="150"
>
<ScrollViewer>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140"/>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Label
Margin="0,6,0,0"
Content="SSID"
Grid.Row="0"
>
</Label>
<TextBox
Margin="0,6,0,6"
Grid.Column="1">
</TextBox>
<Label
Margin="0,6,0,0"
Content="(1024)"
Grid.Column="2"
>
</Label>
<Label
Margin="0,6,0,0"
Content="Authentication Mode"
Grid.Column="0"
Grid.Row="1"
>
</Label>
<ComboBox
Margin="0,6,0,6"
Grid.Row="1"
Grid.Column="1"
ItemsSource="{Binding ACAvailableSecurityTypes}"
SelectedItem="{Binding ACSelectedSecurityType}"
/>
<Label
Margin="0,6,0,0"
Grid.Row="2"
Grid.Column="0"
Content="VLAN"
/>
<TextBox
Margin="0,6,0,6"
Grid.Row="2"
Grid.Column="1"
/>
<Label Grid.Row="2"
Grid.Column="2" …Run Code Online (Sandbox Code Playgroud) 我有一个带有3个组合框的WinForm,一个带有组合框,另外两个带有单选按钮.我将所有这些和他们的子控件设置为"TabStop = false",但是当我使用TAB循环时,最后两个组框中每个组中当前选择的单选按钮会被聚焦.
如果没有办法改变这种行为,那么抓住并将焦点移开会有什么好事?我找不到"OnFocus"活动.
解决方案是设置一个方法(下面的代码)来处理表单中每个单选按钮的"Enter"事件(如果这是你想要的).
实际上,我只是为第一组组的单选按钮做了它并且它工作,第二组框的单选按钮没有得到焦点,即使他们的"Enter"事件没有被处理.这不是您期望的行为.
private void radiobuttonXGroup1_Enter(object sender, EventArgs e)
{
SomeOtherControl.Focus();
}
Run Code Online (Sandbox Code Playgroud)
在*.Designer.cs文件中,您可以编辑每个Enter事件(对于每个单选按钮)以指向一个事件处理程序(上述方法).
this.radiobutton1Group1.Enter += new System.EventHandler(this.radiobuttonXGroup1_Enter);
this.radiobutton2Group1.Enter += new System.EventHandler(this.radiobuttonXGroup1_Enter);
this.radiobutton3Group1.Enter += new System.EventHandler(this.radiobuttonXGroup1_Enter);
Run Code Online (Sandbox Code Playgroud) 我有以下正确显示的 XAML:
<GroupBox Name="RulesGroupBox" Header="Rules">
<StackPanel Name="RulesStackPanel"
HorizontalAlignment="Left">
....
</StackPanel>
</GroupBox>
Run Code Online (Sandbox Code Playgroud)
我现在想使用以下内容(我知道在其他项目中有效)将标题文本设为粗体:
<GroupBox Name="RulesGroupBox">
<GroupBox.Header>
<TextBlock FontWeight="Bold" Text="Rules"></TextBlock>
</GroupBox.Header>
<StackPanel Name="RulesStackPanel"
HorizontalAlignment="Left">
....
</StackPanel>
</GroupBox>
Run Code Online (Sandbox Code Playgroud)
出于某种原因,在此项目中,此更改具有使标题文本“System.Windows.Controls.TextBlock”而不是“Rules”的文本显示的效果。文本现在是粗体但不显示“规则”。
知道为什么 chagne 不会以粗体显示“规则”吗?
我有两个GroupBoxes(groupBox1和groupBox2),每个都包含一组RadioButtons.
问题是在groupBox1中,运行项目时检查了默认值RadioButton(RadioButton组中的第1个),同时groupBox2没有默认选中RadioButton,
我想知道为什么是这样以及如何RadioButton为groupBox2 设置默认选项,并取消选择RadioButtongroupBox1 的默认值.
PS.当我运行项目时,groupBox1 Checked中第一个的属性RadioButton设置为'False'.
namespace RadioButtonsTest
{
partial class RadioButtonsTestForm
{
/// <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(); …Run Code Online (Sandbox Code Playgroud)