private void Window_KeyDown(object sender, KeyEventArgs e) { if ((e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) || e.KeyboardDevice.IsKeyDown(Key.RightCtrl)) && e.Key == Key.N) { if (NewBtn.IsVisible && NewBtn.IsEnabled) { AddCommandHandler(sender, null); } } else if ((e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) || e.KeyboardDevice.IsKeyDown(Key.RightCtrl)) && e.Key == Key.S) { if (SaveBtn.IsVisible && SaveBtn.IsEnabled) { UpdateCommandHandler(sender, null); } } else if ((e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) || e.KeyboardDevice.IsKeyDown(Key.RightCtrl)) && e.Key == Key.F) { if (SearchTxt.IsVisible && SearchTxt.IsEnabled) { SearchTxt.Focus(); } } else if ((e.KeyboardDevice.IsKeyDown(Key.LeftShift) || e.KeyboardDevice.IsKeyDown(Key.RightShift)) && e.Key == Key.Delete) { if (DeleteBtn.IsVisible && DeleteBtn.IsEnabled) { DeleteItemCommandHandler(sender, null); } } }
private void FormItems_KeyDown(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.N) { NewBtn.PerformClick(); } else if (e.Control && e.KeyCode == Keys.S) { SaveBtn.PerformClick(); } else if (e.Shift && e.KeyCode == Keys.Delete) { DeleteBtn.PerformClick(); } else if (e.Control && e.KeyCode == Keys.F) { SearchTxt.Focus(); } }
private void SearchBtn_Click(object sender, RoutedEventArgs e) { //make sure a search value was entered if (string.IsNullOrEmpty(SearchTxt.Text)) { MessageBox.Show("You must enter a search term.", "Missing Search Term", MessageBoxButton.OK); SearchTxt.Focus(); return; } try { //change the cursor to hourglass this.Cursor = Cursors.Wait; PeopleSoapClient ps = new PeopleSoapClient(); //use the host name property to configure the request against the site in //which the control is hosted ps.Endpoint.Address = new System.ServiceModel.EndpointAddress(Utils.GetSiteUrl() + "/_vti_bin/People.asmx"); //create the handler for when the call completes ps.SearchPrincipalsCompleted += new EventHandler <SearchPrincipalsCompletedEventArgs>(ps_SearchPrincipalsCompleted); //execute the search ps.SearchPrincipalsAsync(SearchTxt.Text, 50, SPPrincipalType.User); } catch (Exception ex) { //ERROR LOGGING HERE Debug.WriteLine(ex.Message); MessageBox.Show("There was a problem executing the search; please try again " + "later.", "Search Error", MessageBoxButton.OK); //reset cursor this.Cursor = Cursors.Arrow; } }
private void btnItemsforSale_Click(object sender, EventArgs e) { SearchTxt.Focus(); }
public void FocusText() { SearchTxt.Focus(FocusState.Programmatic); }