本文整理汇总了C#中System.Windows.Controls.ComboBox.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBox.Focus方法的具体用法?C# ComboBox.Focus怎么用?C# ComboBox.Focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ComboBox
的用法示例。
在下文中一共展示了ComboBox.Focus方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Ask
public object Ask(Parameter par)
{
var vlc = main.Children.FindByName(ValueControl);
if (vlc != null)
main.Children.Remove(vlc);
Question.Text = "";
foreach (string s in par.Question.Split(new[] { "\\n" }, StringSplitOptions.None))
{
Question.Inlines.Add(new Run { Text = s });
Question.Inlines.Add(new LineBreak());
}
if (par.ParamType == ParamType.PBool)
{
var value = new ComboBox { Width = 100, Height = 20, Name = ValueControl, Margin = new Thickness(5, 0, 0, 0) };
Grid.SetRow(value, 1);
main.Children.Add(value);
value.Items.Add(Boolean.TrueString);
value.Items.Add(Boolean.FalseString);
value.SelectedIndex = 0;
value.Focus();
}
else
{
var value = new TextBox { Width = 400, Name = ValueControl, Margin = new Thickness(5, 0, 0, 0) };
Grid.SetRow(value, 1);
main.Children.Add(value);
if (par.ParamType == ParamType.PDouble || par.ParamType == ParamType.PFuzzy)
{
value.Text = "0";
value.TextChanged += ValueTextChanged;
value.Tag = par.ParamType;
}
else
value.Tag = ParamType.PString;
value.SelectAll();
value.Focus();
}
if (ShowDialog() == true)
{
UIElement uie = main.Children.FindByName(ValueControl);
if (uie is TextBox)
{
ParamType pt = (ParamType) (uie as TextBox).Tag;
if (pt == ParamType.PDouble || pt == ParamType.PFuzzy)
return double.Parse((uie as TextBox).Text);
return (uie as TextBox).Text;
}
if (uie is ComboBox)
return bool.Parse((uie as ComboBox).Text);
}
return null;
}
示例2: CreateTextFromUserWindow
public void CreateTextFromUserWindow (String PromptString, String ExistingValue)
{
this.WindowStyle = System.Windows.WindowStyle.None;
Grid RootGrid = m_XAML.CreateGrid (new int [] { 2, 1, 1 }, new int [] { 1, 1, 1 });
this.Content = RootGrid;
Label PromptLabel = new Label ();
PromptLabel.MouseLeftButtonDown += new MouseButtonEventHandler (PromptLabel_MouseLeftButtonDown);
PromptLabel.Content = PromptString;
RootGrid.Children.Add (PromptLabel);
Grid.SetColumn (PromptLabel, 0);
Grid.SetRow (PromptLabel, 0);
Grid.SetColumnSpan (PromptLabel, 3);
if (AllowKeyChangeAndAdd == true)
{
Button KeyChangeButton = new Button ();
KeyChangeButton.Content = "ändern/neu..";
RootGrid.Children.Add (KeyChangeButton);
Grid.SetColumn (KeyChangeButton, 0);
Grid.SetRow (KeyChangeButton, 1);
KeyChangeButton.Click += new RoutedEventHandler (KeyChangeButton_Click);
}
Button OKButton = new Button ();
OKButton.Content = "OK";
OKButton.IsDefault = true;
RootGrid.Children.Add (OKButton);
Grid.SetColumn (OKButton, 2);
Grid.SetRow (OKButton, 1);
OKButton.Click += new RoutedEventHandler (OKButton_Click);
Button CancelButton = new Button ();
CancelButton.Content = "Abbrechen";
RootGrid.Children.Add (CancelButton);
Grid.SetColumn (CancelButton, 1);
Grid.SetRow (CancelButton, 1);
CancelButton.Click += new RoutedEventHandler (CancelButton_Click);
if (AllowedValues == null)
{
m_InputBox = new TextBox ();
//m_InputBox.AcceptsReturn = true;
RootGrid.Children.Add (m_InputBox);
Grid.SetColumn (m_InputBox, 0);
Grid.SetRow (m_InputBox, 2);
Grid.SetColumnSpan (m_InputBox, 3);
m_InputBox.Text = ExistingValue;
m_InputBox.Focus ();
}
else
{
m_InputComboBox = new ComboBox ();
m_InputComboBox.IsReadOnly = true;
m_InputComboBox.IsEditable = false;
RootGrid.Children.Add (m_InputComboBox);
Grid.SetColumn (m_InputComboBox, 0);
Grid.SetRow (m_InputComboBox, 2);
Grid.SetColumnSpan (m_InputComboBox, 3);
m_InputComboBox.Focus ();
foreach (String AllowedEntry in AllowedValues)
{
m_InputComboBox.Items.Add (AllowedEntry);
}
m_InputComboBox.SelectedValue = ExistingValue;
m_InputComboBox.Text = ExistingValue;
m_InputComboBox.IsDropDownOpen = true;
}
}
示例3: FillDateControl
private void FillDateControl (ComboBox RessourceGroupSelection, String BookingGroup)
{
BrushConverter BRConverter = new BrushConverter ();
m_DateControlButtons.Children.Clear ();
DataSet Ressources = m_DataBase.GetCommonDataSet ("Select * from Ressource where BookingGroup = '"
+ BookingGroup + "' order by MainAdresse");
m_DateTimeControlButtons = m_XAML.CreateGrid (new int [] { 18, 20, 5, 5, 5, 10 }, new int [] { 1 });
m_DateControlButtons.Children.Add (m_DateTimeControlButtons);
Grid.SetRow (m_DateTimeControlButtons, 0);
Grid.SetColumn (m_DateTimeControlButtons, 2);
FillDateTimeBlock (m_DateTimeControlButtons);
List<String> MainAddresses = new List<string> ();
foreach (DataRow RessourceRow in Ressources.Tables ["Ressource"].Rows)
{
if (MainAddresses.Contains (RessourceRow ["MainAdresse"].ToString ()) == true)
continue;
MainAddresses.Add (RessourceRow ["MainAdresse"].ToString ());
}
if (MainAddresses.Count > 1)
{
Button MainAdressText = new Button ();
m_DateControlButtons.Children.Add (MainAdressText);
MainAdressText.Content = "Block";
Grid.SetRow (MainAdressText, 0);
Grid.SetColumn (MainAdressText, 0);
MainAdressText.FontSize = 20;
MainAdressText.FontWeight = FontWeights.ExtraBold;
MainAdressText.Foreground = (Brush)BRConverter.ConvertFromString ("Black");
MainAdressText.Background = (Brush)BRConverter.ConvertFromString ("#C0C0C0");
ComboBox MainAdresseCombo = new ComboBox ();
m_DateControlButtons.Children.Add (MainAdresseCombo);
MainAdresseCombo.SelectionChanged += new SelectionChangedEventHandler (MainAdresseCombo_SelectionChanged);
Grid.SetRow (MainAdresseCombo, 0);
Grid.SetColumn (MainAdresseCombo, 1);
MainAdresseCombo.FontSize = 20;
MainAdresseCombo.FontWeight = FontWeights.ExtraBold;
MainAdresseCombo.Foreground = (Brush)BRConverter.ConvertFromString ("LightGray");
MainAdresseCombo.Background = (Brush)BRConverter.ConvertFromString ("Blue");
List<String> ProcessMainAdresses = new List<string> ();
foreach (DataRow RessourceRow in Ressources.Tables ["Ressource"].Rows)
{
String MainAdresse = RessourceRow ["MainAdresse"].ToString ();
if (ProcessMainAdresses.Contains (MainAdresse))
continue;
ProcessMainAdresses.Add (MainAdresse);
ListBoxItem NewItem = new ListBoxItem ();
NewItem.Content = MainAdresse;
NewItem.Tag = RessourceRow;
MainAdresseCombo.Items.Add (NewItem);
}
m_TimeControlButtons.Children.Clear ();
m_BookingControlButtons.Children.Clear ();
MainAdresseCombo.IsDropDownOpen = true;
MainAdresseCombo.Focus ();
}
else
{
m_TimeControlButtons.Children.Clear ();
m_BookingControlButtons.Children.Clear ();
ActiveResource = Ressources.Tables ["Ressource"].Rows [0];
FillTimeControl (m_TimeControlButtons, m_BookingControlButtons, Ressources.Tables ["Ressource"].Rows [0]);
RessourceGroupSelection.MoveFocus (new TraversalRequest (FocusNavigationDirection.Next));
}
}
示例4: WorkWithEmailBox
public static ComboBox WorkWithEmailBox(Grid grid, TextBox emailTextBox, TextCompositionEventArgs e, int columnSpanEmailBox)
{
ComboBox comboBox = new ComboBox();
const string val = "@";
if (e.Text != val) return comboBox;
if (emailTextBox.Text.Length < 1) return null;
if (emailTextBox.Text.IndexOf(val, StringComparison.Ordinal) != -1) return comboBox;
Grid.SetColumnSpan(emailTextBox, columnSpanEmailBox);
comboBox.DropDownClosed += (a, r) =>
{
if (comboBox.SelectedIndex == -1) return;
grid.Children.Remove(comboBox);
Grid.SetColumnSpan(emailTextBox, columnSpanEmailBox+2);
if (comboBox.SelectedIndex == 0)
{
emailTextBox.Text += val;
emailTextBox.Focus();
}
else
{
emailTextBox.Text += comboBox.SelectedItem.ToString();
}
emailTextBox.SelectionStart = emailTextBox.Text.Length;
emailTextBox.Focus();
};
Grid.SetRow(comboBox, 2);
comboBox.Items.Add("написать другой");
comboBox.Items.Add(val + "gmail.com");
comboBox.Items.Add(val + "mail.ru");
comboBox.Items.Add(val + "yandex.ua");
comboBox.Items.Add(val + "rambler.ru");
comboBox.Items.Add(val + "hotmail.com");
comboBox.Items.Add(val + "yahoo.com");
comboBox.Items.Add(val + "inbox.ru");
comboBox.Items.Add(val + "list.ru");
comboBox.Items.Add(val + "bk.ru");
comboBox.Items.Add(val + "mail.ua");
comboBox.Height = emailTextBox.ActualHeight;
Grid.SetColumn(comboBox, 4);
Grid.SetColumnSpan(comboBox, 2);
grid.Children.Add(comboBox);
comboBox.IsDropDownOpen = true;
comboBox.Focus();
return comboBox;
}
示例5: FocusTest
public void FocusTest ()
{
ComboBox box = new ComboBox ();
Assert.IsFalse (ComboBox.GetIsSelectionActive (box));
CreateAsyncTest (box,
() => Assert.IsTrue (box.Focus (), "#1"),
() => {
Assert.IsFalse (ComboBox.GetIsSelectionActive (box), "#2");
box.Items.Add ("string");
box.SelectedItem = box.Items [0];
},
() => Assert.IsFalse (ComboBox.GetIsSelectionActive (box), "#3")
);
}
示例6: InitContextMenu
//.........这里部分代码省略.........
#region Exit
mitExit.Header = Comisor.Resource.Exit + "(_X)";
mitExit.Click += new RoutedEventHandler((o, e) => { CloseWindow(); });
#endregion
#region Bookmark
mitBookmark.Header = Comisor.Resource.Bookmark + "(_B)";
mitBookmark.ToolTip = Comisor.Resource.Bookmark_c;
#region Init Add button and textbox
ComboBox cbAdd = new ComboBox();
MenuItem mitAdd = new MenuItem();
cbAdd.MinWidth = 120;
cbAdd.HorizontalAlignment = HorizontalAlignment.Left;
cbAdd.IsEditable = true;
btnAddBookmark.Content = main.resource.imgPlus;
btnAddBookmark.Margin = new Thickness(2);
mitAdd.StaysOpenOnClick = true;
mitAdd.Icon = btnAddBookmark;
mitAdd.Header = cbAdd;
mitBookmark.Items.Add(mitAdd);
mitBookmark.Items.Add(new Separator());
mitBookmark.SubmenuOpened += (o, e) =>
{
System.Collections.Generic.List<string> nameOption = new System.Collections.Generic.List<string>();
nameOption.AddRange(imgInfo.FullName.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries));
ys.DataProcessor.RemoveSame(ref nameOption);
nameOption.Reverse();
cbAdd.ItemsSource = nameOption;
cbAdd.SelectedIndex = 0;
cbAdd.Focus();
};
cbAdd.PreviewKeyDown += (o, e) =>
{
if (e.Key == Key.Enter)
{
btnAddBookmark.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, btnAddBookmark));
}
};
btnAddBookmark.Click += (o, e) =>
{
if (e.OriginalSource is string) cbAdd.Text = e.OriginalSource as string;
Bookmark bk = new Bookmark(cbAdd.Text, imgInfo.FullName);
bookmarks.Insert(0, bk);
Button btnDelete = new Button();
Label lbName = new Label();
MenuItem mit = new MenuItem();
btnDelete.Content = main.resource.imgMinuts;
btnDelete.Margin = new Thickness(2);
btnDelete.Click += (oo, ee) =>
{
bookmarks.Remove(bk);
mitBookmark.Items.Remove(mit);
};
lbName.Content = cbAdd.Text;
mit.Icon = btnDelete;
mit.Header = lbName;
mit.ToolTip = bk.filePath + "\n" + bk.date.ToShortDateString();