Thursday, February 10, 2011

Check Items in a CheckedListBox Based on String Tokens/ String Array (C#)


I have been scouring the internet for days looking for ways to check items in a checkedlistbox based on an array of strings.

After finding bits and pieces of the solution, and translating some code from VB.NET, I finally created something that is extremely short, efficient, and completes the job.





            //This code takes a string and splits it up based on a comma delimiter.
            //You can use any kind of string array you want,
            //just be sure that your strings match the items in your list box!
            string[] yourStringArray = yourObject.yourAttribute.Split(',');
          
            //The foreach iteratures through your array.
            foreach (string strToFind in yourStringArray)
            {

                //This code finds the index of the string. It will return -1 if it doesnt find it
                int itemIndex = yourCheckedListBox.FindString(strToFind);

                //This code provides a safe guard in case it cant find your string
                if (itemIndex != -1)
                {
                    //This code will actually 'check' the item at the index specified,
                    //based on the index previously found
                    yourCheckedListBox.SetItemChecked(itemIndex, true);
                }
            }

Applications: If your storing previous checked options as one long string, this is easy code to 'recheck' those items, and is exactly what I'm using it for.
Also, using "Select All ---" type of buttons would be a great application ff you have a LOT of items to choose from and you want to allow a user to check all of a certain type, etc.

Friday, February 4, 2011

Guide: How to Clear Checked Items from a Checked List Box (C#)

If you've ever played with checked list boxes before, you know that even though the ClearSelected() method clears the underlying selections, it does not remove the visual checks in the checkboxes on the page. To the user, the control still looks 'checked.'

checkedListBoxWorkPerformed.ClearSelected();


You can fix this issue by adding a short loop:



                for (int i = 0; i <= (checkedListBoxWorkPerformed.Items.Count - 1); i++)
                {
                    checkedListBoxWorkPerformed.SetItemChecked(i, false);
                }

The ClearSelected() method will clear the underlying values, and this loop will clear the graphical 'checks.'

Thursday, February 3, 2011

Monday, January 31, 2011

Guide: Creating Transparent, Multiline Labels in VB.NET

To create a transparent background on a label in VB.NET, you must declare a parent to the label, then adjust the color within your form load code.

Example:
The above label was made transparent (so the background picture could show through) by the following code in the form load method:

        lblQuote.Parent = picSpiderman
        lblQuote.BackColor = Color.Transparent


As you may have noticed that labels do not have the boolean 'Multiline' property.

You can make a label multiline in two ways:

~by adjusting the parameters for the 'Maximum Size" property, and setting the Autosize property to true. The text will then autofit into the size you specify.

~by setting the Autosize property to false, and adjust the size of the label directly in the form designer.

Friday, January 21, 2011

Rent Movies for Free @ Redbox and Blockbuster Express

Last Updated: January 21, 2011


My roommate and I rented several free movies last night using Blockbuster Express. Apparently, there are free codes for both Blockbuster and Redbox floating all over the internet. I've compiled some here. If you have any more, or if some that I have listed don't work, let me know!






I have heard that a lot of the Redbox codes do not work in many areas, but that Blockbuster's work most anywhere.


Redbox
DVDONME
DVDKROG (Kroger Stores)
BREAKROOM
DVDATWAG (Walgreen's)
WXM52MD




Blockbuster Express
14CHD2X (Used this one last night, works great!)
ESU11B  (Used this one last night, works great!)
MRC37H
GT14A
GL14A
SSD17A4
SSD17A3
SSD17A2
SSD17A1
SSD16A4
SSD16A3
SSD16A2

Thursday, January 20, 2011

Spotlight: Twitter Gets 'Fit'

What was life like, before the internet? To look up a piece of information we had to dig through our local libraries. Staying in touch meant letters, and phone calls, or packing up the car for a trip. Making friends was usually limited to activities around our locale.
Now, with the touch of a button it is all at our fingertips. We can shop, make friends, share pictures, join support groups, or even go to college--and never leave our house.
I only recently started using Twitter. Once I got passed the ‘new’ Twitter language where everyone uses strange #symbols to talk about specific #topics or @people, it was great fun. However, I soon realized that Twitter is not just used by geeks, gurus,  or tweens writing about every emotion they ever had. You could find specialized groups, planned ‘chats’—entire communities of people with like interests.


One such community I found was #fitblog, a group of Twittering endorphin addicts who enjoy blogging about their fitness journeys.
JimBo @goingfitness was kind enough to talk a bit about the group and his blog:www.goingfitness.com

How did you discover/get involved with #fitblog? 
"Before I started using twitter I was using Google's RSS reader and was following a girl named Lisa Eirene @ http://www.110pounds.com/. One day I finally tried out twitter and saw she mentioned #fitblog so I checked it out."

Why did you start blogging about fitness?
"I deal with tech stuff all day long and it helps to take my mind off work and also helps me to not get burned out on the tech stuff for my job. Plus I wanted to share my Triathlon and Ironman goals with other people and maybe help inspire some people to get outside and move a little. Especially us techno geek-a-zoids that sit on our arse's all day."
How many people would you say use  #fitblog?
"I'd say around 500 - 600 people use #fitblog with maybe 100 or so regulars based on the ones I've been to."

Talk a Little About #runchat:
"#runchat is a 2nd and 4th Sunday (8pm EST) twitter chat for runners. David from Lynchburg Virginia heads it up and info about his blog can be found here: http://www.goingfitness.com/fitnessblogs/runningbecause and his blog is located here: http://www.runningbecauseican.com/. #Runchat is really fun and he gets some big sponsors such as RoadID and EverStride. #runchat is pretty cool, plus you can get lots of help from other runners there."

"It's been really fun meeting people that are interested in the same thing. Twitter is really what makes all this happen."

At the time of this post, JimBo has approximately 244 followers, many of whom he met through #fitblog. His blog provides a wealth of nutritional information, personal stories and recommendations, as well as a substantial directory of other fitness blogs where you can browse, or submit your own.

Wednesday, January 12, 2011

How to Create a Basic Excel Ledger in 10 Minutes or Less

Whether you are trying to keep your checkbook balanced, keep an eye on cash flow, or simply trying to organize your finances, Excel is an invaluable tool. Below, I utilize some of Excel’s basic formulas and functionality to create a ledger that could be applied to a variety of purposes.

1.       First, create your ‘Title’ row. This will list all the information you will be including. I have included Date, Description, Type, Debit, Credit, and Total in this example.
·         Date will store the date of the transaction. For check balancing, the date would be the date on your receipt, not the date you input the information.
·         Description will tell the where/why etc. of the purchase/debit.
·         Type will allow you to keep track of debit purchases vs. checks vs. direct deposits, etc.
·         Debits are transactions that take money OUT of your account. Purchases, etc.
·         Credits are transactions that you credit TO your account. Deposits, etc.
·         Total: will contain a running total.





           
      Secondly, format your tabs. There are many options for how you set up your tabs. In this example, I put each month in a separate tab. However, if you have relatively few transactions each month, you could separate your tabs by year. Also, if you have multiple accounts you are keeping track of, you could separate them using the tabs.


3.       Thirdly, insert your formulas for credit/debit and total. These will be entered in the second row, below your titles. 

      Use the SUM() formulas for the credit/debit rows: 


      For the Total row, you will use ‘=credit cell - debit cell’:


4.      Fourthly, format and freeze. You will be entering data below your title row(s), therefore it’s important that they stand out! In this example,
·         I made all the titles bold (Ctrl+B), with a text size of 12.
·         I then made my credit/debit and total text red, with a text size of 12.

·         I then froze the top two rows so that now matter how long my data gets, I can always see the titles and totals!
     
      To freeze these rows, first click on ‘View’ on the ribbon. Then click on cell A3. While freezing panes manually, Excel always freezes the rows/columns directly above and/or to the left of the cell you have selected. By selecting cell A3, you will freeze the top to rows. Now, try scrolling. Your title/total rows stay in sight!



You are now ready to begin adding data to your ledger!

Example of Simple Ledger: