我有3个单选按钮在网格我怎么能在网格中设置一个单选按钮,“检查”
<dxg:GridColumn x:Name="xrbtCommodityDescription"
FieldName="CommodityDescription"
Header="Commodity Description"
AllowEditing="True"
HeaderTemplate="{StaticResource bold}"
Width="145" MinWidth="60">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<RadioButton x:Name="xrbtCommodityDescription" IsChecked="{Binding Path=Value}"
Checked="RadioButton_Checked" HorizontalAlignment="Center"/>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn x:Name="xrbtCommoditySpanish"
FieldName="CommoditySpanish"
Header="Commodity Description Spanish"
AllowEditing="True"
HeaderTemplate="{StaticResource bold}"
Width="190" MinWidth="60">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<RadioButton x:Name="xrbtCommoditySpanish" IsChecked="{Binding Path=Value}"
Checked="RadioButton_Checked" HorizontalAlignment="Center"/>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn x:Name="xrbtNone"
FieldName="None"
Header="Item Description"
AllowEditing="True"
HeaderTemplate="{StaticResource bold}"
Width="105" MinWidth="40">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<RadioButton x:Name="xrbtNone" IsChecked="{Binding Path=Value}"
Checked="RadioButton_Checked" HorizontalAlignment="Center"/>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
我想“xrbtNone”如果其他两个是假的进行检查,但由于我没有将'xrbtNone'保存到数据库,当我重新打开未选中的界面时。
如何将其设置为检查其他两个是否未选中?
我试图创建一个属性,但它没有工作,这是我为我的单选按钮当前的代码
private void RadioButton_Checked(object sender, RoutedEventArgs e)
{
try
{
var selectedItem = xgrdCustFLDocType.SelectedItem as CustomerFLDocType;
RadioButton RBT = sender as RadioButton;
if ((Boolean)RBT.IsChecked && RBT.Name == "xrbtCommodityDescription")
{
selectedItem.CommodityDescription = true;
selectedItem.CommoditySpanish = false;
selectedItem.None = false;
}
if ((Boolean)RBT.IsChecked && RBT.Name == "xrbtCommoditySpanish")
{
selectedItem.CommoditySpanish = true;
selectedItem.CommodityDescription = false;
selectedItem.None = false;
}
if ((Boolean)RBT.IsChecked && RBT.Name == "xrbtNone")
{
selectedItem.CommoditySpanish = false;
selectedItem.CommodityDescription = false;
selectedItem.None = true;
}
}
catch (Exception ex)
{
ITTaskList.ErrorHandler("Unable To Select Radio Button.", ex, this.Name);
}
finally
{
EnableButtons();
}
}
由于我的单选按钮是在网格中,我无法检查特定的按钮是否被选中或检查特定的按钮,如果它不在网格中,这将工作。 – RickS
啊,gridview。错过了。那么,不知道这样做。 –