Thursday, January 24th, 2008
I’ve added control number 24 to the Toolkit called KryptonListBox.
This control encapsulates the existing WinForms ListBox control but performs custom painting to achieve the Krypton look and feel. Here you can see the control drawn using the Office 2007 – Blue, Office 2003 and System palettes respectively…

Drawing uses the double buffering technique when updating the display so that you no longer get that annoying flicker that occurs with the standard control. If you resize a Form containing a list box you will have noticed this rapid visual flickering, caused by the background being drawn before the list entries.
The control is implemented by using a container that draws the border and background elements and contains in the client area an instance of the ListBox. This has the advantage of allowing the border to have rounded corners and any other effects as required by the selected palette. Unfortunately it has the side effect and preventing the IntegralHeight functionality from working. Personally I do not see this as an issue as I’ve never found a use for this property.
Other properties not provided are ColumnWidth, MultiColumn and UseTabSpaces. These are not used because the text drawing is handled by the same internal class that performs button drawing. This internal class does not have the functionality required to implement the removed properties. However, it’s not all bad news. Instead of being limited to just showing text you can easily provide an additional string and image for display. Just like this…

Defining the additional item values is very simple. Just create instances of KryptonListItem and add them to the Items collection property. The control will notice that the item instance exposes the IContentValues interface and use that to recover the three values. If the interface is not found it reverts to the standard behavior of calling ToString() on the item object. If you prefer to use your own custom objects inside the collection then simply implement the IContentValues.
As with all Krypton controls you can alter the State properties to alter the appearance and manipulate the relative positions of the content values. So if you prefer both text strings right aligned with the image above the text, then you just need to alter the appropriate appearance properties to achieve it.
I hope that the addition of the KryptonListItem class will make up for the loss of the IntegralHeight and multiple columns capabilities that have been lost.
Posted in Krypton Toolkit | 12 Comments »
Thursday, January 17th, 2008
You can now debug into the .NET Framework code when working with Visual Studio 2008.
There have been many times when it would have been very helpful to set breakpoints in the base classes such as Control. Until now I used .NET Reflector to see the base code implementation, but that is hard work to follow.
Follow these instructions to get started…
Step-by-Step Guide
Posted in .NET | 2 Comments »
Thursday, January 17th, 2008
Given how often you need to select colors from within applications it makes sense to create a specialized version of the recently added KryptonDropButton that handles this common scenario. The KryptonColorButton allows the user to select a color using a context menu. Here is the out of the box appearance…

The red color block is drawn using the SelectedColor property value which itself generates a SelectedColorChanged event whenever it changes. The size and location of this red block is defined by the SelectedRect property. So if you prefer your color block to appear at a different place then you can customize the setting. Here is an example where the rectangle has been adjusted to be 0,0,16,16…


This size covers the entire image and so you cannot see any of the default image. This is great if you want a large solid block of color as user feedback. Note that the color block overlays the defined image so if you alter the image it could affect the drawing of the solid color block. If you remove the image then you will not see any color block because there is no image for it to overlay.
This is the appearance of the context menu by default…

You can alter the text strings that appear by updating the child properties of the Strings composite property. Also you can turn on and off which parts of the context menu appear. Here I have removed the Standard, ‘No Color‘ and ’More colors…‘ parts of the menu and changed the name and color scheme of the remainder…

If you really want to be radical then hook into the DropDown event and completely change the contents of the context menu or e.Cancel the event and show you own context menu instead. Hopefully the current implementation will handle the majority of scenarios.
Posted in Krypton Toolkit | No Comments »
Tuesday, January 15th, 2008
I have added a new property to the KryptonDropButton called Splitter, a boolean indicating if the drop down button should be placed in a separate split area. This is how it looks with the drop down button in each of the four possible positions…




And just to prove that it really operates as a split button here are the tracking and pressed states for the two different areas…

If you press the main part of the button you get the Click event fired. If you press in the split area instead then you get the DropDown event. You only get one or the other event and not both.
Ideally we would not have three separate buttons called KryptonButton, KryptonCheckButton and KryptonDropButton. It would have been better to have a single button that had a type property to switch functionality. However, I do not want to change the existing controls because it would disrupt existing applications built on the Toolkit. Besides it is hardly the end of the world for the developer to choose between three button controls.
Posted in Krypton Toolkit | 3 Comments »
Monday, January 14th, 2008
KryptonDropButton is a new Toolkit control that does exactly what you would expect, showing a context menu when pressed. You can specify a traditional ContextMenuStrip or KryptonContextMenu although I certainly recommend you use the Krypton version because of its enhanced functionality.
Here you can see the new control with each variation of the DropDownPosition property…


You can alter the orientation of the drop down button using the DropDownOrientation property…


By default the context menu will be shown in a relative position to the control that makes sense given the DropDownOrientation property. So if the button is pointing downwards it shows the context menu below the button. Here the arrow is pointing to the right and so by default the menu appears to the right hand side…


You can hook into the DropDown event which is fired just before the menu is shown. This allows you to customize the contents of the menu and set the correct menu item states before it is made visible. Or you can cancel the event entirely and prevent the menu from being shown, allowing you to show some other control or window instead.
Posted in Krypton Toolkit | 5 Comments »