无法创建滚动条C#Windows窗体

问题描述 投票:-1回答:1

我是C#开发人员的初学者,所以这就是为什么我只使用Windows窗体的原因。

我目前正在尝试在我的C#应用​​程序中放置一个scrollBar(使用Windows窗体)即使我在Windows窗体中使用滚动条对象(滚动条仍处于禁用状态(灰色))

    <GroupBox Header="Setting" Margin="5,0,5,0" Grid.Row="1">
        <ScrollViewer HorizontalScrollBarVisibility="Auto" IsManipulationEnabled="True">

        <TabControl x:Name="tabSetting" Margin="5,0,5,0" >
        <TabItem x:Name="Tab_CmdSettings" Header="CMD settings">
             <Grid Name="grid_CMD_settings" ScrollViewer.CanContentScroll="True">
             <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="8*"/>
                  <ColumnDefinition Width="10*"/>
             </Grid.ColumnDefinitions>
             <Label Content="A1A2 fall voltage (% Un_min)" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0"/>
             <TextBox x:Name="textBox_buff_dtr" Height="21" TextWrapping="Wrap" Text="nvm_dtr" HorizontalAlignment="Left" Margin="0,3,0,0" VerticalAlignment="Top" Width="120" Grid.Column="1" />
             <Label x:Name="label_Unmin" Content="Un_min= " HorizontalAlignment="Left" Margin="130,0,0,0" VerticalAlignment="Top" Grid.Column="1"/>
             <Label Content="A1A2 rise voltage (% Un_max)" HorizontalAlignment="Left" Margin="0,20,0,0" VerticalAlignment="Top" Grid.Column="0"/>
...
...

或我尝试在表单中使用适当的AutoScroll =“ true”。但是它没有被重新认识,并且在编译过程中一直处于崩溃状态

   <GroupBox Header="Protection Parameters" Grid.Row="0" Grid.ColumnSpan="2" AutoScroll="True">
       <Grid Name="grid_Protection" AutoScroll="True">
       <Grid.ColumnDefinitions>
           <ColumnDefinition Width="84*"/>
           <ColumnDefinition Width="145*"/>
           <ColumnDefinition Width="287*"/>
       </Grid.ColumnDefinitions>

       <Label Content="Short circuit function selection" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0" Grid.ColumnSpan="2"/>
      <RadioButton x:Name="radioButton_buff_enascc_On" GroupName="group_enascc" Content="Enable" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Top" Grid.Column="2" IsChecked="True"/>
      <RadioButton x:Name="radioButton_buff_enascc_Off" GroupName="group_enascc" Content="Disable" HorizontalAlignment="Left" Margin="100,5,0,0" VerticalAlignment="Top" Grid.Column="2" />
      <Label Content="Short circuit current level (x Ir_max)" HorizontalAlignment="Left" Margin="0,20,0,0" VerticalAlignment="Top" Grid.Column="0" Grid.ColumnSpan="2"/>
      <TextBox x:Name="textBox_buff_ie3scc" Height="21" TextWrapping="Wrap" Text="nvm_ie3scc" HorizontalAlignment="Left" Margin="0,23,0,0" VerticalAlignment="Top" Width="120" Grid.Column="2" />
   </GroupBox>
...
</Grid>
...
</TabItem>
...

有人知道我在做什么错吗?放置滚动条或添加自动调整大小是不够的吗?必须使用C#代码编写吗?

c# wpf scrollbar windows-forms-designer
1个回答
0
投票

根据WinForms的属性,使AutoScroll属性为True

滚动条将仅出现

  • 如果Form元素的内容大于实际的Form Control

  • 如果Form不适合屏幕的屏幕分辨率。

© www.soinside.com 2019 - 2024. All rights reserved.