Tuesday, 15 February 2011

Better debugging with RadControlSpy

Telerik controls are simple wrappers and do not implement detailed functionality. Rather, each control has as a direct descendant an instance of the RootRadElement class. This RootRadElement wraps the actual functionality of the control and acts to transfer events to and from the RadControl class.

In turn, the RootRadElement has a descendant tree of RadElement classes that implement the actual logic required by the control. Because of this, when you want to change a property of a RadControl or add a new element to extend it, you will find the RadControlSpyForm really useful.

The RadControlSpyForm is a tool to let you examine the detailed internal structure of any RadControl. It is not a stand-alone tool. Rather, the Control Spy is supplied as part of a library that you compile into your application. After adding this library, you can start the Control Spy and use it to examine and alter properties of any RadControl which is currently running.

So, let's start with a simple scenario. You have a RadListControl on your form, and you change the back color property.

Me.RadListControl1.BackColor = Color.Red

but when you run your application, you see that the back color has not changed.

So, we need RadControlSpy.
  • Add a reference to the RadControlSpy assembly. By default, you can find a copy in C:\Program Files\Telerik\Telerik RadControls for WinForms<current version>\Examples\bin
  • In your form load event, add the following (VB example)
        Dim form As New RadControlSpy.RadControlSpyForm()

So, we were able to find the correct area to set the back color for the list control. RadControlSpy is really powerful and is useful for finding out all sorts of information about your RadControls.

No comments:

Post a Comment