Radio Buttons
オプション「新規」と「既存」の2つがあります。が空のDevexpress TextEdit
場合の Validate イベントがあり、 にエラー アイコンが表示されます。
シナリオ: [新規]を選択して TextEdit を空のままにして [保存] をクリックすると、エラー アイコンが表示されますが、これは正常に機能します。しかし、「既存」に切り替えようとすると、オプションを切り替える/変更することはできず、代わりに検証のために「新規」オプションに固執します。しかし、ユーザーがラジオボタンのオプションを変更できるようにしたい。TextEdit
TextEdit
Radio button
Radion button
Xaml:
<RadioButton x:Name="rbNew" Content="New Mapping" Grid.Column="1" HorizontalAlignment="Left" Margin="0,10,0,0" VerticalAlignment="Top" GroupName="Mappings" GotFocus="rbNew_GotFocus"/>
<dxe:TextEdit x:Name="txtMappingName" Grid.Column="1" Height="23" Margin="0,31,0,0" TextWrapping="Wrap" VerticalAlignment="Top" MaxLength="100" Grid.RowSpan="2" GotFocus="txtMappingName_GotFocus" Validate="txtMappingName_Validate" />
<RadioButton x:Name="rbExisting" Content="Existing Mapping" Grid.Column="1" HorizontalAlignment="Left" Margin="0,6,0,0" VerticalAlignment="Top" Grid.Row="1" GroupName="Mappings"/>
xaml.cs
private void txtMappingName_Validate(object sender, DevExpress.Xpf.Editors.ValidationEventArgs e)
{
if ((bool)rbNew.IsChecked && string.IsNullOrEmpty(e.Value as string))
{
e.IsValid = false;
e.ErrorContent = "Required";
e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Warning;
}
}
助けて感謝!ありがとう!