Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
575
How do I refer to Infragistics objects generically?
posted
private void AddTextToDocumentObject(ref object tempObj, string TextToAdd,int Relative_Width, Infragistics.Documents.Graphics.Font f,Infragistics.Documents.Graphics.Brush b, bool ApplyBold,bool ApplyItalic,bool ApplyUnderline)

{

Infragistics.Documents.Report.Text.IText tempText = null;

if (tempObj is Infragistics.Documents.Report.IGroup)

{

tempText = ((Infragistics.Documents.Report.
IGroup)tempObj).AddText();

}

if (tempObj is Infragistics.Documents.Report.Flow.IFlow)

{

tempText = ((Infragistics.Documents.Report.Flow.
IFlow)tempObj).AddText();

}

tempText.Style =
new Infragistics.Documents.Report.Text.Style(f, b);

tempText.Style.Font.Bold = ApplyBold;

tempText.Style.Font.Italic = ApplyItalic;

tempText.Style.Font.Underline = ApplyUnderline;

tempText.AddContent(TextToAdd);

if (tempObj is Infragistics.Documents.Report.IGroup)

{

((Infragistics.Documents.Report.
IGroup)tempObj).Width = new RelativeWidth(Relative_Width);

}

if (tempObj is Infragistics.Documents.Report.Flow.IFlow)

{

((Infragistics.Documents.Report.Flow.
IFlow)tempObj).Width = new RelativeWidth(Relative_Width);

}

}

 

 

I want to be able to pass in different KINDS of Infragistics objects, like Group or Flow  objects, and "Add Text"  to those objects.

 

 But when I try to call the above, I get an error:

 

Error: A ref or out argument must be an assignable

 

Parents
  • 575
    posted

    In essence, what I am trying to do is combine these two methods into ONE method that handles the different kinds of objects.  In this case, adding text to either Group or Flow.

    (NOTE:  These two methods work just fine, and they pretty much differ ONLY in the kind of object being passed in!!  That is why I want to merge them!)!:

     


         private void AddTextToGroup(ref IGroup tempGroup,
            string TextToAdd,
            int Relative_Width,       
            Infragistics.Documents.Graphics.Font f,
            Infragistics.Documents.Graphics.Brush b,
            bool ApplyBold,
            bool ApplyItalic,
            bool ApplyUnderline)
        {
            Infragistics.Documents.Report.Text.IText tempText = tempGroup.AddText();       
            tempText.Style = new Infragistics.Documents.Report.Text.Style(f, b);       
            tempText.Style.Font.Bold = ApplyBold;
            tempText.Style.Font.Italic = ApplyItalic;
            tempText.Style.Font.Underline = ApplyUnderline;
            tempText.AddContent(TextToAdd);
            tempGroup.Width = new RelativeWidth(Relative_Width);
        }
     
        private void AddTextToFlow(ref Infragistics.Documents.Report.Flow.IFlow tempFlow,
            string TextToAdd,
            Infragistics.Documents.Graphics.Font f,
            Infragistics.Documents.Graphics.Brush b,
            bool ApplyBold,
            bool ApplyItalic,
            bool ApplyUnderline)
        {
            Infragistics.Documents.Report.Text.IText tempText = tempFlow.AddText();
            tempText.Style = new Infragistics.Documents.Report.Text.Style(f, b);
            tempText.Style.Font.Bold = ApplyBold;
            tempText.Style.Font.Italic = ApplyItalic;
            tempText.Style.Font.Underline = ApplyUnderline;
            tempText.AddContent(TextToAdd);
        }

Reply Children