我的网格设计如下:
这是用于网格的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] 我的网格看起来像上面。我专注于第一场。在按下选项卡时,我希望焦点移动到City字段而不是下一个单元格New Field。
有什么建议吗?
[1]: http://i.stack.imgur.com/ENqqP.png
答案 0 :(得分: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
}
}