8,735
社区成员
发帖
与我相关
我的任务
分享
<hc:ComboBox FocusVisualStyle="{x:Null}" IsEditable="True" KeyDown="UIElement_OnKeyDown" Tag="car7" TextBox.SelectionChanged="Txtms_OnSelectionChanged1" GotFocus="Txtms_OnGotFocus" LostFocus="Txtms_OnLostFocus" Name="cbx0" VerticalContentAlignment="Center" tools:BorderElement.CornerRadius="0" BorderBrush="#999999" Width="293" tools:InfoElement.ContentHeight="50" FontSize="16px" Foreground="#1a1a1a" HorizontalAlignment="Left" Height="50" BorderThickness="1" DockPanel.Dock="Left" />
private void UIElement_OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
ComboBox cbx = sender as ComboBox;
Grid gr = cbx.Parent as Grid;
DataGridTemplateColumn templeColumn = dg.Columns[0] as DataGridTemplateColumn;
FrameworkElement s = dg.Columns[0].GetCellContent(dg.Items[int.Parse(gr.Tag.ToString()) + 1]);
var tbOper = templeColumn.CellTemplate.FindName("cbx0", s) as HandyControl.Controls.ComboBox;
//DataGridCell cell = GetCell(dg, int.Parse(gr.Tag.ToString()) + 1, 0);
//cell.IsSelected = true;
tbOper.Background = Brushes.Yellow;
tbOper.Text = "123";
tbOper.RaiseEvent(new RoutedEventArgs(ComboBox.GotFocusEvent));
}
}