Introduction
This will just be a small article, it won't explain how to create a user control since it's quite straightforward, it won't tell you how the control works because there is not much to it, it will tell you what it does and how you can use it in your own projects, since that's the real purpose of any control. Of course, if you have any doubts, downloading and looking through the code will help you get started. The user control source code and/or binary can be downloaded and used in anyway you like.
Features
The control contains a dynamic button array; dynamic means you can create a matrix of buttons of any size, even at run time.
The control features a big button that can be placed on top or on the bottom, and if you don't want it, you can make it invisible. You can put one or several images on the buttons, you can specify the button's sizes or their separation, you can have them laid out in four different ways, left to right (L2R), right to left (R2L), top to bottom (T2B), or bottom to top (B2T). You can also set the text and the image alignment for all the buttons, among other design time properties.
Using the control
|
Using the control is very easy. First, you have import it to the toolbox. You can do this either by dragging the control's DLL or by browsing and adding the item. Once you get it on your toolbox, you just drag it and drop it on your project form and it's default 3x3 matrix layout will appear.
Then just edit the properties to fit your needs, just like any other control you've used before. The properties I implemented come with a short description, however, if you don't figure it out with that, you can look at the code to see how it all works, or you can write to me.
Pretty simple, right? |
Some unbeaten issues
I did have some problems during the development, I thought I had finished the control quite well because some tests had passed fine, but then I tried new ones and a lot of problems came up. When developing a control, it is a little harder to test it all.
You must test at design time and run time too; anyway, the most challenging issues I worked out were the layout, the creation of the matrix, and the resizing at design time.
There are basically two issues I just couldn't work out, so if you read this and have some suggestions or any tips, they are more than welcomed. I wanted my control to have a nice icon, but it just wouldn't show. I added the icon I wanted to the project properties but when I added the control to the toolbox, it would always show the same default icon.
The other thing I couldn't get working was the button's texts. I wanted them to be modified at design time, so I created an ArrayList
as a property so that it would show at design time, and it did, but it wouldn't let me modify them, just see them. So then I thought about using a collection editor just like the combobox.Item
string collection editor, but no matter what I tried I got the same result, "read-only". I don't know if I have to make my own collection editor but it shouldn't be like that.
Last words
I hope the control helps you. I can think of many uses for it. So I hope yours is one of them. I'd appreciate to get a word from any one that uses it telling me how it's doing.
Any questions or comments are always more than welcomed.