AutoScroll in WinForms

Every time I need to adjust AutoSize and/or AutoScroll in WinForms, it’s always a struggle to get things working and looking right. Hopefully this post will help me avoid this struggle the next time I have to do it.

To enable AutoScroll on a panel, AutoSize must be false. If the panel is contained within another panel, that panel’s AutoSize must also be false. If any of the panels are a TableLayoutPanel, the row containing the control that needs to AutoScroll must be set to Percent, 100. All controls within all of these panels must be set to Dock.Fill. Lastly, if adding controls dynamically to any of the panels, set them to Dock.Top.


Using images from another project in VS 2010

This post is a little self-serving, as I might be the only one who needs to know this in the future, but I’m sure I’ll forget all about this some day when I google this problem and find the answer in my own post.

Today I needed to use an image that was in one VS2010 project in a control of another project in the same solution. While you can certainly copy and paste the image into both resource files, I found a way that I can share the same file.

Step 1: Right-click the project you want the image in and choose ‘Unload Project’ from the context menu.
Step 2: Right-click the project again and choose ‘Edit [project name].csproj’.
Step 3: Find a <ItemGroup> section and insert the following code into it:

,EmbeddedResource Include="..\[project name]\Properties\Resources.resx">
    <Link>[assembly name].Properties.Resources.resx</Link>
    <LastGenOutput>[assembly name].Properties.Resources.Designer.cs</LastGenOutput>
    <CustomToolNamespace>[assembly name].Properties</CustomToolNamespace>

Replace “[project name]” with the actual name of the project that contains the resource file of the image you want to use.
Replace “[assembly name]” with the actual name of the assembly for the project.

Step 4: Right-click the project and choose ‘Reload Project’. If prompted, allow VS to close the .csproj file.
Step 5: When you bring up the Image picker dialog for the control, you’ll now have the new resource file to choose from in the dropdown menu:


Live Coding in Technical Interviews

Prior to Mentis, no employer I have ever interviewed with had asked me to write live code. At Mentis I interviewed with 4 separate people who asked me to write code on a whiteboard. After Mentis I had one other interview with a small startup company, and they also asked me to write live code. I’m surprised that some employers don’t require this in their interviews. To me it makes perfect sense to include code writing in the interview when you’re looking to hire a programmer.

I fortunately do not have anxiety while writing code for an audience. In fact, I feel more comfortable writing code than I do talking about what I’ve done. For those that do have anxiety though, Scott Hanselman has a great post about how to deal with anxiety when coding live in technical interviews. The only thing I feel I can add is, regardless of whether or not you feel anxiety writing code on-the-spot, it can be helpful to explain to the interviewer additional steps that you would normally take in addition to what you show them. For example, if you rely on IDE tools such as auto-complete, documentation links, or Internet searches, these may be things that you should mention. If you normally refactor your work several times before calling it done, this may also be something to mention. Ultimately, when you explain your process for creating quality code, this will supplement what you’ve shown them.

Start Raising Awareness for Something You Care About

Start raising awareness for something you care about. One man asks people to care about ALS, and Facebook explodes with ice-bucket challenges. Meanwhile, 21,000 children will die today from poverty, hunger, easily preventable diseases and illnesses, and other related causes. Millions more won’t die today, but they suffer from one thing or another. Are their lives any less important than the lives of people who have ALS? Don’t get me wrong; if you care about ALS, then raise awareness about ALS. But also raise awareness about other things that you care about.

Among other things, I care about toxoplasmosis. This disease killed my beautiful, innocent nephew. I am not going to dump a bucket of ice over my head, but I have donated and will continue to donate to help prevent this disease.

While I’m on the topic of donations, everyone should know that charitable donations are tax-deductible. What this means is, the more you donate to causes that you care about, the less the government takes away from you to waste or give to causes that you don’t care about. So don’t whine and complain about where your hard-earned tax dollars go. Instead, reduce your taxes by deliberately choosing where your money is going to go. I’m not saying by any means that we shouldn’t keep our government in check by exposing how they waste tax money. I believe that is important, but let’s give the government less of our money to waste by choosing to donate where it will do the most good.

In addition to personal donations, we should all shop at businesses that donate portions of their proceeds to charity (preferably a charity that we care about). When businesses donate, not only can they do more to help the causes that we care about, but just like individuals, they also get taxed less as a result. The government gets even less money to waste when we deliberately take care of others in need.

Time to Start Blogging

I’ve finally decided what to use my blog for. In the past few months I’ve come across some pretty challenging tasks in my work. I find that when I discover a solution to a problem I’m working on, it’s generally the same problem that others have already dealt with. Nine times out of ten, the overall solution I end up with is a collaboration of others’ efforts. The tenth time, the solution is my own custom creation, having not found good enough examples. In all cases, however, I find that I come up with the best solution by talking it out.

So that’s what the majority of these blog posts will be. They’ll be my experience of a problem, the possible solutions I’ve come across, the solution I ended up with, and how I arrived at that decision. If I can’t explain it well enough, then chances are it wasn’t the right solution, and I may have to go back to the drawing board. I also hope to gain feedback through my posts of others’ experiences, whether I’ve helped them with my solution, or whether I’ve shown them what not to do and they can correct my flaws. So each post will be a learning experience, in one shape or another.

I’d like to make some connections through blogging, and to build some long-lasting friendships and/or business relationships. Please check out my about page to see if we have similar interests, and drop me a line if you’d like. Thanks!