/// <summary> /// Insert text. /// </summary> /// <param name="text">Text to insert</param> /// <param name="replaceSelection">Determines if selected text should be replaced or not</param> /// <param name="insertAtRight">If true and replaceSelection is false, the inserted text will be inserted at the right /// boundary of the selection instead of the left boundary.</param> protected void insertText(string text, bool replaceSelection, bool insertAtRight) { int selLen = m_textbox.SelectionLength; int selStart = m_textbox.SelectionStart; int newSelStart = selStart + text.Length; int newSelLength = 0; if (replaceSelection) { if (selLen > 0) { m_textbox.Text = m_textbox.Text.Remove(selStart, selLen); } m_textbox.Text = m_textbox.Text.Insert(selStart, text); } else { if (insertAtRight) { m_textbox.Text = m_textbox.Text.Insert(selStart + selLen, text); selStart += selLen; } else { m_textbox.Text = m_textbox.Text.Insert(selStart, text); m_textbox.Select(selStart + text.Length, 0); } } m_textbox.Focus(); // Do select AFTER focus, otherwise, focus changes selection to whole box. m_textbox.Select(newSelStart, newSelLength); m_textbox.Refresh(); }
/// <summary> /// translate up and down arrow keys in the Find textbox into moving the selection in /// the matching entries list view. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void m_tbForm_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Up: m_matchingObjectsBrowser.SelectPrevious(); e.Handled = true; m_tbForm.Select(); break; case Keys.Down: m_matchingObjectsBrowser.SelectNext(); e.Handled = true; m_tbForm.Select(); break; } }
/// <summary> /// Insert text. /// </summary> /// <param name="text">Text to insert</param> /// <param name="replaceSelection">Determines if selected text should be replaced or not</param> /// <param name="insertAtRight">If true and replaceSelection is false, the inserted text will be inserted at the right /// boundary of the selection instead of the left boundary.</param> protected void InsertText(string text, bool replaceSelection, bool insertAtRight) { int selLen = m_textbox.SelectionLength; int selStart = m_textbox.SelectionStart; int newSelStart = selStart + text.Length; const int newSelLength = 0; var bldr = m_textbox.Tss.GetBldr(); if (replaceSelection) { if (selLen > 0) { m_textbox.Text = m_textbox.Text.Remove(selStart, selLen); } bldr.Replace(selStart, selStart, text, null); m_textbox.Tss = bldr.GetString(); } else { if (insertAtRight) { bldr.Replace(selStart + selLen, selStart + selLen, text, null); m_textbox.Tss = bldr.GetString(); } else { bldr.Replace(selStart, selStart, text, null); m_textbox.Tss = bldr.GetString(); m_textbox.Select(selStart + text.Length, 0); } } m_textbox.Focus(); // Do select AFTER focus, otherwise, focus changes selection to whole box. m_textbox.Select(newSelStart, newSelLength); m_textbox.Refresh(); }
public void SetDlgInfo(FdoCache cache, Mediator mediator, ICmObject owner) { CheckDisposed(); m_cache = cache; m_owner = owner; m_helpTopic = "khtpDataNotebook-InsertRecordDlg"; m_helpTopicProvider = mediator.HelpTopicProvider; if (m_helpTopicProvider != null) // Will be null when running tests { m_helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile; m_helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(m_helpTopic)); m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic); } IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator); m_titleTextBox.StyleSheet = stylesheet; m_titleTextBox.WritingSystemFactory = m_cache.WritingSystemFactory; m_titleTextBox.WritingSystemCode = m_cache.DefaultAnalWs; AdjustControlAndDialogHeight(m_titleTextBox, m_titleTextBox.PreferredHeight); m_typeCombo.StyleSheet = stylesheet; m_typeCombo.WritingSystemFactory = m_cache.WritingSystemFactory; m_typeCombo.WritingSystemCode = m_cache.DefaultAnalWs; AdjustControlAndDialogHeight(m_typeCombo, m_typeCombo.PreferredHeight); ICmPossibilityList recTypes = m_cache.LanguageProject.ResearchNotebookOA.RecTypesOA; m_typePopupTreeManager = new PossibilityListPopupTreeManager(m_typeCombo, m_cache, mediator, recTypes, cache.DefaultAnalWs, false, this); m_typePopupTreeManager.LoadPopupTree(m_cache.ServiceLocator.GetObject(RnResearchNbkTags.kguidRecObservation).Hvo); // Ensure that we start out focused in the Title text box. See FWR-2731. m_titleTextBox.Select(); }
void control_Click(object sender, EventArgs e) { m_textBox.Select(); }