コード例 #1
0
ファイル: TextMaker.cs プロジェクト: Unripe01/FixedTextMaker
        private void btnAddRow_Click(object sender, EventArgs e)
        {
            MyTextBox.SelectionChanged -= richTextBox_SelectionChanged;
            var tabTemp    = tabControlMain.SelectedTab;
            var index      = MyTextBox.GetFirstCharIndexOfCurrentLine();
            var insertText = GetSelectedTabsString();

            if (!MyTextDataAdapter.HasCrLf)
            {
                insertText = insertText + "\r\n";
            }
            var nextIndex = index + insertText.Length;

            MyTextBox.Text           = MyTextBox.Text.Insert(index, insertText);
            MyTextBox.SelectionStart = nextIndex;

            tabControlMain.SelectedTab  = tabTemp;
            MyTextBox.SelectionChanged += richTextBox_SelectionChanged;
            MyTextBox.Focus();
        }