Problem adding RichTextBox as child

4 posts, 0 answers
  1. Michael Maddux
    Michael Maddux avatar
    11 posts
    Member since:
    May 2010

    Posted 13 Feb 2012 Link to this post


    Our telerik dlls all have the version: 2011.3.1323.1040

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

    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!!


    Mike Maddux

  2. Martin Ivanov
    Martin Ivanov avatar
    104 posts

    Posted 16 Feb 2012 Link to this post

    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,
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. Rajmund
    Rajmund avatar
    2 posts
    Member since:
    Feb 2012

    Posted 30 Mar 2012 Link to this post

    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)
                    if(parent != null)
                    rtb = parent.FindName(rtb.Name) as RadRichTextBox;

    and this woking OK on Silverlight 5 and Telerik 2012.1.215.1050 trial
  4. Martin Ivanov
    Martin Ivanov avatar
    104 posts

    Posted 03 Apr 2012 Link to this post

    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.

    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top