Archive for the ‘Krypton Toolkit’ Category

One of the new features of .NET Framework 4.0 is the introduction of Client Profiles. The Client Profile is a cut down version of the full .NET Framework that only includes the essential assemblies needed for client based applications. The idea is to reduce the download/install size for this common deployment scenario. Design time classes are not part of the client profile because they are implicitly only needed for designing and not for running your applications.

At the moment Krypton cannot be used in this situation because the Krypton design time classes are placed inside the same assembly as the relevant controls. So the Krypton Toolkit design time classes are inside the Toolkit assembly, Krypton Ribbon design time classes inside the Ribbon assembly and so forth. But the design time assembly is not included in the client profile and so the Krypton assemblies will not be loadable.

To enable this scenario I have now created a new ComponentFactory.Krypton.Design assembly and moved all the design time classes into it. This means you can write a client profile application that references the Krypton Toolkit/Ribbon/Navigator/Workspace/Docking assemblies and it will work just fine because the Krypton assemblies no longer reference the System.Design namespace.

Note that client profiles are a feature exposed in Visual Studio 2010 and so you will only be aware of them if you have downloaded and played with that version.

It seems I cannot get away without having button specs on the new columns. So I’ve added a ButtonSpecs collection to the column class of each of the following types…

  • DateTimePicker
  • MaskedTextBox
  • NumericUpDown
  • DomainUpDown
  • ComboBox

Here you can see a couple of example images…

To make life a little easier for the developer I have added a ButtonSpecClick event onto the columns that is fired whenever any button spec is clicked for any cell in that column. This event has parameters that made it easy to get hold of the column, cell and button spec instances involved in that click. Stops you needing to walk around the data structures finding your way from the button spec to the cell and then the column, which although not hard is certainly a pain to work out each time you need to do it.

Note that there are no button specs on the already defined Krypton columns  TextBox/CheckBox/Button/Link. This is because they work in a different way that makes it impractical to add them. All the new columns have an instance of an actual control that is used when editing the cell. So when you click on a numeric column it uses a KryptonNumericUpDown instance perform the drawing and editing. As the KryptonNumericUpDown already has support for button specs this makes it possible to add that capability by moving the button specs from the column collection into the control for the duration of editing. But the TextBox/CheckBox/Button/Link columns all perform drawing by using direct calls to the renderer and adding extra code to simulate the presence of buttons is not a pleasant thought.

I thought the MaskedTextBox column would be the last addition for the DataGridView but it seems there is more interest in columns than I anticipated. I was trying to think of other useful ones. Would a column for editing a colour be useful? Does anyone actually need to do this at the moment? What data type is the column itself?

Apart from a drop button and colour column what others are people in need of? I cannot promise to add what people request but if it sounds generally useful and not overly time consuming to add then I will certainly consider it.

Our final addition in a series of new column types allows a KryptonMaskedTextBox to be used for displaying and editing cells values. Here you can see two columns using the new column… 

I setup the first column with a mask of “(99) 9999-9999″ and the second is defined to use the system password character in order to hide the underlying text value. Using the masked text box is a great way of achieving a formatted appearance to underlying string values and also ensuring the user can only enter valid values.

Editing dates and times in the KryptonDataGridView is a requirement for almost all business applications. Well now its easy with the addition of the inconveniently long named column type of KryptonDataGridViewDateTimePickerColumn. You can use the column type to edit DateTime typed columns as shown here…

All three columns are defined using our new column type but by altering the Format, CustomFormat and other column properties we can choose to only show and allowing editing of the Date part, Time part or both. It can handle null able columns as well, just remember to set the ShowCheckBox to True for a null able column so that the user can make an entry null able again after setting a DateTime value.