2016-06-17 1 views
-3

콤보 상자를 편집/선택하도록 사용자를 차단하고 싶습니다. 나는 cmbbox.IsReadOnly = Truecmbbox.IsEditable = False을 사용해 보았는데, 사용자가 altarrow' keys으로 선택을 변경할 수있다. cmbbox.isEnabled = False 작동하고 제 요구 사항은 '블랙'으로 전환 할 때 콤보 박스의 전경색을 변경하는 것입니다. 누구든지 나를 고칠 수 있도록 도와 주시겠습니까?비활성화 상태에서 콤보 박스의 전경을 변경하는 방법은 무엇입니까?

<telerik:RadComboBox Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="2" x:Name="combobox1" IsEditable="True" IsFilteringEnabled="True" ItemsSource="{Binding}" TabIndex="7" Style="{ DynamicResource DropDownListStyle }" IsTabStop="True" KeyboardNavigation.TabNavigation ="Local" SelectAllTextEvent="None" Height="23" Margin="0,0,0,2" VerticalAlignment="Center"/> 

Codebehind가에서 : XAML에서

스타일에서
combobox1.IsEnabled = False 

:

<Style x:Name="DropDownListStyle" x:Key="DropDownListStyle" TargetType="telerik:RadComboBox" > 
       <Setter Property="Foreground" Value="#FF000000"/> 
       <Setter Property="BorderBrush" Value="#ffcccccc"/> 
       <Setter Property="BorderThickness" Value="1"/> 
       <Setter Property="HorizontalContentAlignment" Value="Left" /> 
       <Setter Property="VerticalContentAlignment" Value="Center" /> 
       <Setter Property="FontSize" Value="12"/> 
       <Setter Property="FontWeight" Value="Thin"/> 
       <Setter Property="FontFamily" Value="Trebuchet MS"/> 
       <Setter Property="Panel.ZIndex" Value="10" /> 
       <Setter Property="Height" Value="23" /> 
       <!-- <Setter Property="Focusable" Value="True"/> --> 
       <Style.Triggers> 
        <Trigger Property="IsEnabled" Value="False"> 
         <Setter Property="Background" Value="White"/> 
         <Setter Property="Foreground" Value="Black"/> 
        </Trigger> 
       </Style.Triggers> 
      </Style> 
+0

코드 –

+0

중 일부는 실제로 당신의 질문을 수정하고 지금까지 작성한 코드를 추가 좋을 것이다 공유하십시오 : [최소, 전체를 만드는 방법, 및 확인 가능한 예제?] (http://stackoverflow.com/help/mcve). –

답변

0

IsReadonly = True 속성을 combobox으로 설정하고 PreviewKeyDown 이벤트를 트리거하여 해결했습니다.

combobox1.IsReadonly = True 

Private Sub combobox1_PreviewKeyDown(sender As Object, e As Windows.Input.KeyEventArgs) Handles combobox1.PreviewKeyDown 
     If combobox1.IsReadOnly Then 
      If e.Key = Key.Tab Then 
       e.Handled = False 
      Else 
       e.Handled = True 
      End If 
     End If 
End Sub 
0

가이 콤보 상자를 변경하는 사용자를 방지하려면 읽기 전용을 사용하지 않고 또는를 사용 ComboBox SelectedIndexChanged 이벤트에서이 작업을 시도 할 수 있습니다.

코드를 보지 않아도 특정 문제에 도움을 줄 수 없습니다.

'Inform the user 
MsgBox("You can't change this drop down") 
'Reset any choice 
e.NewValue = e.CurrentValue 

e는 선택한 인덱스 변경 이벤트를 선택할 때 전달되는 이벤트 인수입니다.

관련 문제