YCC List Control is an open source user control created in Microsoft Visual Basic .NET 2008 which handles many of the common tasks associated with a list of data. YCC List Control is a graphical interface to open, save, and edit data which is then displayed in a standard
ListBox control. Additionally, the programmer is able to programmatically edit data, import data, and change various aspects of the
ListBox such as the currently highlighted entry.
- Change the text and color of the
GroupBox that contains the
- Increment and decrement the selected index
- Graphically open, append, and save a list
- Graphically add or remove an item from the list
- Programmatically get, set, or delete the currently selected item
- Programmatically replace, add, or delete any item based on item text
- Import a data set (array of values) into the
- Various events showing what operations have been completed
Rational and Background
On more than one occasion, I have found myself needing a general use control that imported and manipulated a list of data. It seems that most of my projects involve a list of names, passwords, or accounts so after about the third time of recreating the same functionality in individual programs, I decided to create a general utility control that could be used for all of these projects and even future projects. Since its initial creation, YCC List Control has had many features added and tweaked but the basic principal remained the same.
YCC List Control is a
ToolStrip inside a
ListBox is standard but the
ToolStrip has been modified to remove the line that usually separates itself from the main content. Within the
ToolStrip, there are buttons to add a list, append to a list (keep what is there and add to it), save what is currently in the list, add a value to the list, and remove the selected value. With each operation, a line count is kept and displayed in the
GroupBox text. All of these operations are meant for the end-user to load their lists into the parent program and then have the data accessible to other parts of the parent program.
Once the data is in the parent program, the programmer must have a way to retrieve and use the data. A common operation is to get the currently selected item and then increment the selected index for the next
get operation. This can be accomplished with the following two lines:
txtGetCurret.Text = YLCMain.GetSelectedValue
There are also inverses to the above operations and a programmer can also set the current item value or decrement the selected index.
Another common operation is to remove a particular value from the list once it is found that the item in question is no longer valid. This can be accomplished by the following.
Other operations such as deleting the current item, replacing an item with another item, and adding an item can be performed programmatically. Another feature of YCC List Control is the data is also kept in a string array separate from the
ListBox. This allows the programmer to retrieve and import the data as a string array if it better fits the programming model.
The most well known use of the YCC List Control is in YCC Yahoo! Bot Maker which uses the control in the proxy list. Here the YCC List Control gets the selected proxy from the list and then increments the selected index for the next proxy. If an error occurs with the proxy, that proxy is removed from the list.
Using the Code
YCC List Control is a standard user control and can be added to any project programmatically or through the Visual Studio Designer. When in design mode, make sure the Toolbox is showing by selecting View and then Toolbox (crtl + alt + x). Right click on the Toolbox and select Choose Items… A Choose Toolbox Items dialogue pops up and under the .NET Framework Components tab, click Browse. Select the location of YCC List Control/bin/Debug/ YCC List Control.dll and then click Open. You will notice a new item in the Toolbox named YCC List Control and you can now use it like any other form control.
YCC List Control and many other useful programs are housed at Yahoo! Coder's Cookbook (http://ycoderscookbook.com/). Also at Yahoo! Coder's Cookbook is a full tutorial section explaining much of the Yahoo! Messenger protocol, a frequently updated blog, other code samples for Yahoo! Messenger, and much more.