2015-05-06 64 views
0

裏面我有一個像下面電網設計的東西:如何在列焦點移動一個網格單元

這是XAML用於電網: - 我使用的DevExpress gridcontrol在我的應用程序。

<dxg:GridControl ItemsSource="{Binding MyAddresses}"> 
     <dxg:GridControl.View> 
      <dxg:TableView NavigationStyle="Cell"></dxg:TableView> 
     </dxg:GridControl.View> 
     <dxg:GridControl.Columns> 
      <dxg:GridColumn Name="MyAddress" Header="Address" MinWidth="725"> 
       <dxg:GridColumn.CellTemplate> 
        <DataTemplate> 
         <Grid DataContext="{Binding RowData.Row}" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="5"> 
          <Grid.RowDefinitions> 
           <RowDefinition Height="Auto"></RowDefinition> 
           <RowDefinition Height="5"></RowDefinition> 
           <RowDefinition Height="Auto"></RowDefinition> 
           <RowDefinition Height="5"></RowDefinition> 
           <RowDefinition Height="Auto"></RowDefinition> 
           <RowDefinition Height="5"></RowDefinition> 
           <RowDefinition Height="Auto"></RowDefinition> 
           <RowDefinition Height="5"></RowDefinition> 
           <RowDefinition Height="Auto"></RowDefinition> 
           <RowDefinition Height="5"></RowDefinition> 
           <RowDefinition Height="Auto"></RowDefinition> 
          </Grid.RowDefinitions> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="Auto"></ColumnDefinition> 
           <ColumnDefinition Width="5"></ColumnDefinition> 
           <ColumnDefinition MinWidth="250"></ColumnDefinition> 
           <ColumnDefinition Width="25"></ColumnDefinition> 
           <ColumnDefinition Width="Auto"></ColumnDefinition> 
           <ColumnDefinition Width="5"></ColumnDefinition> 
           <ColumnDefinition MinWidth="250"></ColumnDefinition> 
          </Grid.ColumnDefinitions> 

          <TextBlock Grid.Row="0" Grid.RowSpan="3" Grid.Column="0" Text="Address"/> 
          <dxe:TextEdit Grid.Row="0" TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top" Grid.RowSpan="3" Grid.Column="2" MaxLength="2000" VerticalAlignment="Stretch" Text="{Binding PostAddress}"/> 

          <TextBlock Grid.Row="6" Grid.Column="0" Text="Country" /> 
          <dxe:TextEdit Grid.Row="6" Grid.Column="2" Text="{Binding PostCountry}"/> 

          <TextBlock Grid.Row="4" Grid.Column="0" Text="City" /> 
          <dxe:TextEdit Grid.Row="4" Grid.Column="2" MaxLength="100" Text="{Binding City}"/> 

          <TextBlock Grid.Row="8" Grid.Column="0" Text="Postal Code" /> 
          <dxe:TextEdit Grid.Row="8" Grid.Column="2" MaxLength="15" Text="{Binding PostalCode}"/> 

          <TextBlock Grid.Row="10" Grid.Column="0" Text="Subdivision" /> 
          <dxe:TextEdit Grid.Row="10" Grid.Column="2" MaxLength="100" Text="{Binding Subdivision}"/> 

          <TextBlock Grid.Row="0" Grid.Column="4" Text="Email" /> 
          <dxe:TextEdit Grid.Row="0" Grid.Column="6" MaxLength="254" Text="{Binding Email1}"/> 

          <TextBlock Grid.Row="2" Grid.Column="4" Text="Phone" /> 
          <dxe:TextEdit Grid.Row="2" Grid.Column="6" MaxLength="20" Text="{Binding Phone1}"/> 

          <TextBlock Grid.Row="4" Grid.Column="4" Text="Phone" /> 
          <dxe:TextEdit Grid.Row="4" Grid.Column="6" MaxLength="20" Text="{Binding Phone2}"/> 

          <TextBlock Grid.Row="6" Grid.Column="4" Text="Fax" /> 
          <dxe:TextEdit Grid.Row="6" Grid.Column="6" MaxLength="50" Text="{Binding Fax1}"/> 

          <TextBlock Grid.Row="8" Grid.Column="4" Text="Telex" /> 
          <dxe:TextEdit Grid.Row="8" Grid.Column="6" MaxLength="100" Text="{Binding Telex}"/> 

          <TextBlock Grid.Row="10" Grid.Column="4" Text="Web" /> 
          <dxe:TextEdit Grid.Row="10" Grid.Column="6" MaxLength="255" Text="{Binding Web}"/> 

         </Grid> 
        </DataTemplate> 
       </dxg:GridColumn.CellTemplate> 
      </dxg:GridColumn> 
      <dxg:GridColumn FieldName="NewField"/> 
     </dxg:GridControl.Columns> 
    </dxg:GridControl> 

在我有幾列第一個單元格,我想在第一個單元格移動光標,然後跳轉到第二單元。

有人可以請幫忙。 ![輸入圖片描述] [1] 我的網格看起來像上面。我專注於第一個領域。在按下標籤我想焦點移動到城市字段不是下一個單元格是新場。

有什麼建議嗎?

[1]: http://i.stack.imgur.com/ENqqP.png 

回答

0

同樣的問題在DevExpress的支持中心已經討論:Tabbing issue in CellTemplate。因此,您可以使用DevExpress支持團隊提供的解決方案。

該方案的主要思想是在TabbedView.PreviewKeyDown事件的自定義處理:

void TableView_PreviewKeyDown(object sender, KeyEventArgs e) { 
    if (e.Key == Key.Tab) { 
     // do some custom handling 
     e.Handled = true; // avoid TabbedView's default focus processing 
    } 
} 
+0

感謝@DmitryG – vishal

相關問題