如何设置默认选择的字段
你好,我不知道如何设置默认选择的字段 这是我的代码:
<DockPanel>
<Grid DockPanel.Dock="Left" Height="426">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="63"/>
<RowDefinition Height="79"/>
</Grid.RowDefinitions>
<Label Foreground="blue" Margin="0,1,0,4" Height="26">Message Number:</Label>
<Label Grid.Row="1" Foreground="blue" Margin="0 10 0 0">Title:</Label>
<Label Grid.Row="2" Foreground="blue" >Message Date:</Label>
<Label Grid.Row="3" Foreground="blue" Margin="0 10 0 0">Contact Mail:</Label>
<Label Grid.Row="4" Foreground="blue" Margin="0 10 0 0">Message Type:</Label>
<Label Grid.Row="5" Foreground="blue" Margin="0 10 0 0">Message Details:</Label>
<Button Grid.Row="6" Name="saveBtn" Background="White" Margin="6,20,11,36" Width="89" Click="saveBtn_Click">Save</Button>
<TextBox Grid.Column="1" Name="IDtbx" Margin="0 10 0 0"></TextBox>
<TextBox Grid.Row="1" Grid.Column="1" Name="titletbx" Margin="0 10 0 0"></TextBox>
<Calendar Grid.Row="2" Grid.Column="1" Name="calender"></Calendar>
<TextBox Grid.Row="3" Grid.Column="1" Name="mailtbx" Margin="0 10 0 0"></TextBox>
<ComboBox Grid.Row="4" Grid.Column="1" Name="typecbx" Margin="0 10 0 0"></ComboBox>
<TextBox Grid.Row="5" Grid.Column="1" Name="detailstbx" Margin="0,10,0,1" TextWrapping="Wrap" AcceptsReturn="True"></TextBox>
</Grid>
<DockPanel>
<Grid DockPanel.Dock="Left" Height="406">
<Grid.RowDefinitions>
<RowDefinition Height="372"></RowDefinition>
<RowDefinition Height="7"/>
<RowDefinition Height="27*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border CornerRadius="6" BorderBrush="Purple" BorderThickness="3" Margin="18,8,0,7" Grid.RowSpan="2" Width="182">
<Image Grid.Row="1" Name="messageImage" Height="359" Width="177"></Image>
</Border>
<Button Name="ChangeImagebtn" Background="white" Content="Change Image" Grid.Row="2" Margin="21,2,0,-2" Click="ChangeImagebtn_Click"></Button>
</Grid>
</DockPanel>
</DockPanel>
当我运行程序时,由于某种原因,保存按钮被选中,但我不希望它被选中。 预先感谢您的帮助
hello i dont know how how to set a field to be selected by default
this is my code:
<DockPanel>
<Grid DockPanel.Dock="Left" Height="426">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="63"/>
<RowDefinition Height="79"/>
</Grid.RowDefinitions>
<Label Foreground="blue" Margin="0,1,0,4" Height="26">Message Number:</Label>
<Label Grid.Row="1" Foreground="blue" Margin="0 10 0 0">Title:</Label>
<Label Grid.Row="2" Foreground="blue" >Message Date:</Label>
<Label Grid.Row="3" Foreground="blue" Margin="0 10 0 0">Contact Mail:</Label>
<Label Grid.Row="4" Foreground="blue" Margin="0 10 0 0">Message Type:</Label>
<Label Grid.Row="5" Foreground="blue" Margin="0 10 0 0">Message Details:</Label>
<Button Grid.Row="6" Name="saveBtn" Background="White" Margin="6,20,11,36" Width="89" Click="saveBtn_Click">Save</Button>
<TextBox Grid.Column="1" Name="IDtbx" Margin="0 10 0 0"></TextBox>
<TextBox Grid.Row="1" Grid.Column="1" Name="titletbx" Margin="0 10 0 0"></TextBox>
<Calendar Grid.Row="2" Grid.Column="1" Name="calender"></Calendar>
<TextBox Grid.Row="3" Grid.Column="1" Name="mailtbx" Margin="0 10 0 0"></TextBox>
<ComboBox Grid.Row="4" Grid.Column="1" Name="typecbx" Margin="0 10 0 0"></ComboBox>
<TextBox Grid.Row="5" Grid.Column="1" Name="detailstbx" Margin="0,10,0,1" TextWrapping="Wrap" AcceptsReturn="True"></TextBox>
</Grid>
<DockPanel>
<Grid DockPanel.Dock="Left" Height="406">
<Grid.RowDefinitions>
<RowDefinition Height="372"></RowDefinition>
<RowDefinition Height="7"/>
<RowDefinition Height="27*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border CornerRadius="6" BorderBrush="Purple" BorderThickness="3" Margin="18,8,0,7" Grid.RowSpan="2" Width="182">
<Image Grid.Row="1" Name="messageImage" Height="359" Width="177"></Image>
</Border>
<Button Name="ChangeImagebtn" Background="white" Content="Change Image" Grid.Row="2" Margin="21,2,0,-2" Click="ChangeImagebtn_Click"></Button>
</Grid>
</DockPanel>
</DockPanel>
when i run the program the save button is getting to be selected for some reason and i dont want it to be.
thanks in advance for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为第一个按钮是被选中的按钮 - 但我很可能是错的。
您可以通过设置
IsDefault
属性设置为 true。如果要将焦点设置到文本框,则可以
在
Window
定义中使用:。MSDN 页面
I think that the first button is the one that gets selected - but I could well be wrong on that.
You can specify which button you want to be the default by setting the
IsDefault
property of another button to true.If you want to set the focus to a text box then you can use:
in the
Window
definition.MSDN page