Exemplo n.º 1
0
        private void richEditControl1_HyperlinkClick(object sender, HyperlinkClickEventArgs e)
        {
            if (e.ModifierKeys != this.richEditControl1.Options.Hyperlinks.ModifierKeys)
            {
                return;
            }

            //Initialize the custom form
            SelectProductForm control = new SelectProductForm(products);

            //Subscribe it to the OnCommit event
            control.Commit += OnProductFormCommit;

            //Connect the form with the hyperlink range
            control.Range = e.Hyperlink.Range;

            //Associate the form with the FloatingContainer instance
            FloatingContainer container = FloatingContainerFactory.Create(FloatingMode.Window);

            control.OwnerWindow = container;
            container.Content   = control;
            container.Owner     = this.richEditControl1;
            ((ILogicalOwner)this.richEditControl1).AddChild(container);

            //Set the form's location and size
            container.SizeToContent            = SizeToContent.WidthAndHeight;
            container.ContainerStartupLocation = WindowStartupLocation.Manual;
            container.FloatLocation            = GetFormLocation();
            container.IsOpen  = true;
            this.activeWindow = container;
            control.Focus();

            e.Handled = true;
        }
Exemplo n.º 2
0
        // Handle the event to replace the hyperlink with the selected item value:
        void OnProductFormCommit(object sender, EventArgs e)
        {
            SelectProductForm form     = (SelectProductForm)sender;
            string            value    = (string)form.EditValue;
            Document          document = this.richEditControl1.Document;

            document.BeginUpdate();
            document.Replace(form.Range, value);
            //Uncomment this line to remove the clicked hyperlink once a desired value has been selected
            //richEditControl1.Document.Hyperlinks.Remove(activeLink);
            document.EndUpdate();
        }
Exemplo n.º 3
0
        void OnHyperlinkClick(object sender, HyperlinkClickEventArgs e)
        {
            activeLink = e.Hyperlink;
            SelectProductForm form = new SelectProductForm(products);

            // Set the Commit event handler:
            form.Commit += OnProductFormCommit;
            //Set the Range property to the hyperlink range:
            form.Range = activeLink.Range;
            //Set the Location property to specify the location where the form is going to be invoked:
            form.Location = GetFormLocation();
            form.Show();
            e.Handled = true;
        }
Exemplo n.º 4
0
        void OnProductFormCommit(object sender, EventArgs e)
        {
            SelectProductForm form = (SelectProductForm)sender;

            //Retrieve the selected item value
            string   value    = (string)form.EditValue;
            Document document = this.richEditControl1.Document;

            //Start the document modification
            document.BeginUpdate();

            //Replace the hyperlink range content
            //with the retireved value
            document.Replace(form.Range, value);

            //Finish the document update
            document.EndUpdate();
        }