This is a migrated thread and some comments may be shown as answers.

Problem adding RichTextBox as child

3 Answers 93 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael Maddux
Top achievements
Rank 1
Michael Maddux asked on 13 Feb 2012, 08:41 PM
Hi,

Our telerik dlls all have the version: 2011.3.1323.1040

I am trying to implement the printing example that uses RadRichTextBox found here:

http://demos.telerik.com/silverlight/#GridView/PrintAndExportWithRadDocument

I am getting an exception when I try to add the RadRichTextBox as a child to the parent of the RadGridView.  I have simplified my code so as to more clearly demonstrate the error.

Here is the XAML:

                <telerikGrid:RadGridView x:Name="RadGridView1"></telerikGrid:RadGridView>
                <telerik:RadButton x:Name="PrintButton" Content="Print" Click="PrintButton_Click" />

And here is the click event handler:
		private void PrintButton_Click(object sender, RoutedEventArgs e)
		{
			Grid parent = RadGridView1.ParentOfType<Grid>();
	
			var tb = new TextBox() { Height = 0 };
			tb.Name = "NormalTextBox";
			parent.Children.Add(tb);	// works fine
 
			var rtb = new RichTextBox() { Height = 0 };
			rtb.Name = "NormalRichTextBox";
			parent.Children.Add(rtb);	// works fine
 
			var rb = new RadButton();
			rb.Name = "RadButton1";
			parent.Children.Add(rb);	// works fine
 
			RadRichTextBox rrtb = new RadRichTextBox() { Height = 0 };
			rrtb.Name = "RadRichTextBox1";
			parent.Children.Add(rrtb);  // exception thrown here!
		}




I included cases that work fine so you can more easily see the contrast.

The exception has the message: "Error HRESULT E_FAIL has been returned from a call to a COM component."

The stack trace is:
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection`1 collection, CValue value)
   at MS.Internal.XcpImports.Collection_AddDependencyObject[T](PresentationFrameworkCollection`1 collection, DependencyObject value)
   at System.Windows.PresentationFrameworkCollection`1.AddDependencyObject(DependencyObject value)
   at System.Windows.Controls.UIElementCollection.AddInternal(UIElement value)
   at System.Windows.PresentationFrameworkCollection`1.Add(T value)
   at Pmc.Views.Controls.ManufacturingStylesControl.PrintButton_Click(Object sender, RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at Telerik.Windows.Controls.RadButton.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)


Please help if you can!!

Thanks,


Mike Maddux





3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 16 Feb 2012, 05:59 PM
Hi Michael,

There are some issues with this particular demo which are about to be fixed.
We, however, couldn't reproduce the mentioned problem. You could try to use transparent RadRichTextBox:

RadRichTextBox rtb = new RadRichTextBox() { Opacity = 0 };
instead of one with zero height:
RadRichTextBox rtb = new RadRichTextBox() { Height = 0 };
In case this doesn't fix the problem, you could send us (through a support ticket) sample project that reproduces it, so we can investigate it further.

Kind regards,
Martin
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Rajmund
Top achievements
Rank 1
answered on 30 Mar 2012, 10:22 AM
I have the same error. Problem is with
Name = "RadRichTextBox1";

Is that name declared in RadGridView ?
I'm using code:
RadGridView grid = (RadGridView)parameter;
            RadRichTextBox rtb = new RadRichTextBox() { Height = 0 };
            rtb.Name = "RadRichTextBox1";
            
            Grid parent = grid.ParentOfType<Grid>();
            if (parent != null && parent.FindName(rtb.Name) == null)
            {
                parent.Children.Add(rtb);
                rtb.ApplyTemplate();
            }
            else
            {
                if(parent != null)
                rtb = parent.FindName(rtb.Name) as RadRichTextBox;
            }

and this woking OK on Silverlight 5 and Telerik 2012.1.215.1050 trial
0
Martin Ivanov
Telerik team
answered on 03 Apr 2012, 11:36 AM
Hi Rajmund,

Mike contacted us through the support ticketing system and it turned out that the problem was related to the fact that his application used a custom theme. The resources for Telerik.Windows.Documents were missing, which was the cause of the issue.

As for your other question, RadGridView does not use RadRichTextBox and the name RadRichTextBox1 is not declared in the control. If you are not able to resolve the issue, we would appreciate a sample project to help us investigate the cause.

Regards,
Martin
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
RichTextBox
Asked by
Michael Maddux
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Rajmund
Top achievements
Rank 1
Share this question
or