Пример #1
0
        private void AddTextControlAtRange()
        {
            this.Paragraphs[1].Range.InsertParagraphBefore();

            textControl2 = this.Controls.AddPlainTextContentControl(this.Paragraphs[1].Range,
                                                                    "textControl2");
            textControl2.PlaceholderText = "Enter your first name";
        }
Пример #2
0
        private void AddTextControlAtSelection()
        {
            this.Paragraphs[1].Range.InsertParagraphBefore();
            this.Paragraphs[1].Range.Select();

            textControl1 = this.Controls.AddPlainTextContentControl("textControl1");
            textControl1.PlaceholderText = "Enter your first name";
        }
Пример #3
0
        //</Snippet5>

        //<Snippet6>
        void plainTextContentControl1_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Microsoft.Office.Tools.Word.PlainTextContentControl control =
                sender as Microsoft.Office.Tools.Word.PlainTextContentControl;

            if (control != null)
            {
                System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\d");
                if (regex.IsMatch(control.Text))
                {
                    MessageBox.Show("Invalid name. Names cannot contain integers.");
                    e.Cancel = true;
                }
            }
        }
Пример #4
0
        private void CreateTextControlsFromNativeControls()
        {
            if (this.ContentControls.Count <= 0)
            {
                return;
            }

            plainTextControls = new System.Collections.Generic.List
                                <Microsoft.Office.Tools.Word.PlainTextContentControl>();
            int count = 0;

            foreach (Word.ContentControl nativeControl in this.ContentControls)
            {
                if (nativeControl.Type == Word.WdContentControlType.wdContentControlText)
                {
                    count++;
                    Microsoft.Office.Tools.Word.PlainTextContentControl tempControl =
                        this.Controls.AddPlainTextContentControl(nativeControl,
                                                                 "VSTOPlainTextContentControl" + count.ToString());
                    plainTextControls.Add(tempControl);
                }
            }
        }