I'm trying to get this VB example to work in Progress:
Public Function HasVertScrollBar(ByVal UG As Infragistics.Win.UltraWinGrid.UltraGrid) As Boolean
Dim aRowScrollbarUIElement As Infragistics.Win.UltraWinGrid.RowScrollbarUIElement
aRowScrollbarUIElement = UG.DisplayLayout.UIElement.GetDescendant(GetType(Infragistics.Win.UltraWinGrid.RowScrollbarUIElement))
Return Not aRowScrollbarUIElement Is Nothing
End Function
My code is:
METHOD PUBLIC LOGICAL HasVertScrollBar(UG As Infragistics.Win.UltraWinGrid.UltraGrid):
DEFINE VARIABLE myRowScrollbarUIElement AS Infragistics.Win.UltraWinGrid.RowScrollbarUIElement NO-UNDO.
myRowScrollbarUIElement = UG:DisplayLayout:UIElement:GetDescendant(Progress.Util.TypeHelper:GetType( "Infragistics.Win.UltraWinGrid.RowScrollbarUIElement" )).
RETURN VALID-OBJECT(myRowScrollbarUIElement).
END METHOD.
I'm getting an "Incompatible data types in expression or assignment" error on the line with GetType.
Please let me know if I'm doing something incorrectly here. The method is supposed to show whether there's a vertical scrollbar being displayed.
Thanks,
JL
Can't test this right now, but try to CAST the whole expression to Infragistics.Win.UltraWinGrid.RowScrollbarUIElement
Like:
myRowScrollbarUIElement = CAST(UG:DisplayLayout:UIElement:GetDescendant(Progress.Util.TypeHelper:GetType( "Infragistics.Win.UltraWinGrid.RowScrollbarUIElement" )), Infragistics.Win.UltraWinGrid.RowScrollbarUIElement).
The GetDescendant just returns the basic Infragistics.Win.UIElement. You need to cast it up to return the scrollbar UI element type.
The GetDescendant just returns the basic
Infragistics.Win.UIElement. You need to cast it up to
return the scrollbar UI element type.
Why would this work in vb, and not ABL ? (i.e. why do we have to cast in the ABL and not VB)
As a C# guy, I could only guess (supported by the rumors, that VB.NET supports dirty coding) that VB.NET tries to cast automatically. I quickly looked up the class hierarchy of the RowScrollbarUIElement and guessed that a CAST should to the trick.
Let's see what he finds out and we'll know for sure...
The casting did work, but it would have been nice for the code to be more similar. For reference, here's the same code in C#:
public bool HasVertScrollBar(Infragistics.Win.UltraWinGrid.UltraGrid UG)
{
Infragistics.Win.UltraWinGrid.RowScrollbarUIElement aRowScrollbarUIElement;
aRowScrollbarUIElement = (Infragistics.Win.UltraWinGrid.RowScrollbarUIElement)UG.DisplayLayout.UIElement.GetDescendant
(typeof(Infragistics.Win.UltraWinGrid.RowScrollbarUIElement));
return (aRowScrollbarUIElement != null);
}
I'm not a .NET developer (until now -ish :>) but is the (Infragistics.Win.UltraWinGrid.RowScrollbarUIElement) sort of an automatic casting? Figuring out that I needed to do the cast in the manner you suggested would not have occurred to me.
Just an FYI, while the casting method works, in either case, even if the scrollbar is there, the method isn't returning a true value until the Form_Shown event, and only if I performed a grid:Refresh().
Thanks for the help This should give me what I want.
JL
The casting did work, but it would have been nice for
the code to be more similar. For reference, here's
the same code in C#:
abl .net coding is much more like c# than vb, so I would use c# examples wherever possible.
I think that typeof in c# is CAST in ABL.
That's the CAST syntax in C# (naming the target Type in parenthesis)
aRowScrollbarUIElement = (Infragistics.Win.UltraWinGrid.RowScrollbarUIElement)
So it's actually very close to the ABL code - just a different grammar. During Exchange/PSDN live it has been discussed that PSC should come up with a short white paper on how to translate C# and VB.NET code to ABL.
The CAST Syntax, usage of . and ; and : and all the helper classes (I hate using the EnumHelper) should be on that White Paper.
I think that typeof in c# is CAST in ABL.
No exactly and that's really confusing.
typeof in C# returns a type reference. TYPE-OF in ABL is actually more of a CAN-CAST type.
typeof in C# is similar to the TypeHelper:GetType ().
And exactly why a translation white paper is in order :>)
Backwards compability?
We all love that when it saves us time to market. We hate it when it causes delays in availability of features in the compiler
So Jim can you now post the literal OOABL translation of the C# code?
Sure.
What I ended up with is pretty much what Mike posted:
METHOD PUBLIC LOGICAL HasVertScrollBar(UG As Infragistics.Win.UltraWinGrid.UltraGrid):
DEFINE VARIABLE myRowScrollbarUIElement AS Infragistics.Win.UltraWinGrid.RowScrollbarUIElement NO-UNDO.
myRowScrollbarUIElement = CAST(UG:DisplayLayout:UIElement:GetDescendant(Progress.Util.TypeHelper:GetType("Infragistics.Win.UltraWinGrid.RowScrollbarUIElement")),
Infragistics.Win.UltraWinGrid.RowScrollbarUIElement).
RETURN VALID-OBJECT(myRowScrollbarUIElement).
END METHOD. /* HasVertScrollBar */
It works, but as I said, this particular property isn't available for valid info until the form_shown event.
JL
Hello, Can you guys help me with this? How this C# code will look in ABL?
public ToolboxServiceImp GetIToolboxService() {
return (ToolboxServiceImp) this.GetService( typeof( IToolboxService ) );
}
It'll look something like:
method public ToolboxServiceIM GetIToolboxService():
return cast(this-object:GetService( Progress.Lang.Class:GetClass('IToolboxService'),ToolboxServiceImp),
IToolboxService) .
end method.
There's a mapping guide at http://communities.progress.com/pcom/docs/DOC-16316 which may also be helpful.
-- peter
Maybe something like this:
METHOD PUBLIC ToolboxServiceImp GetIToolboxService ():
RETURN CAST (THIS-OBJECT:GetService (Progress.Util.TypeHelper:GetType ("System.Drawing.Design.IToolboxService")), ToolboxServiceImp) .
END METHOD.