Finding what you need in the Microsoft� Visual Studio� documentation, which has over 200,000 topics, can be a daunting task. The Doc Detective is here to help, utilizing his investigative skills to probe the depths of the documentation.
Can't find what you're looking for? Just ask - if it's in there, I'll find it for you; if it isn't, I'll let you know that as well (and tell you where else you might go to find it).
Have a question for the Doc? Send your questions for future columns to me at docdetec@microsoft.com.
Dear Doc Detective,
I am in the process of redesigning a Windows Forms application that uses the DataGridView
control in several places. I would like to use WPF for the redesign, but the lack of a DataGridView
control is a major issue. My users prefer the grid and balk at other alternatives I've shown them. What can I do?
- Gridlocked in Greeley
Dear Gridlocked,
If your users want a grid, give them a grid. Version 4 of the .NET Framework now contains a full-featured DataGrid
control for WPF. Like the DataGridView
control, it enables you to display data in rows and columns by using data binding. You can also customize the look and behavior by using the styling capabilities of WPF.
Just look in the MSDN Library for the topic “DataGrid Class”, or the end-to-end walkthrough topic “Walkthrough: Display Data from a SQL Server Database in a DataGrid Control”. Ask and you shall receive.
- Doc D
Dear Doc Detective,
Back in the days of Visual Basic 6 you could start a Windows Forms application with either a startup form or a Sub Main. Starting with Sub Main allowed you to perform some code (like check settings or command line parameters) before determining which form to display.
In Visual Basic .NET I cannot find a way to do this. Someone suggested that I make it a console app so it could start with Sub Main, but that doesn't seem right. Is there any way to handle this properly?
- Subdued in Sudbury
Dear Subdued,
You can handle it properly by using Sub Main. Although the first version of the .NET Framework didn't support Sub Main as the startup
object, the capability has existed ever since version 2.0.
You can tell your application to use Sub Main as your startup
object instead of a form by changing the Startup Object property on the Application tab of the Project Designer. This is described in the topic "How to: Change the Startup Object for an Application (Visual Basic)". It even has a procedure section named “To set the startup
object for a Windows Application to Sub Main” - it doesn't get much clearer than that.
- Doc Detective
Dear Doc Detective,
I recently started using Windows 7 and I'm impressed by the new capabilities of the taskbar. For example, the taskbar button for Windows Media Player can display a thumbnail of a running video. It even allows you to pause a video while the application is minimized.
I'd like to provide the same sort of features for my applications when running on Windows 7. Is there any way to do this in Visual Studio, or is this super-secret Windows API stuff?
- Envious in Encino
Dear Envious,
The Windows team denies the existence of the DoubleSecretProbation API. Fortunately version 4 of the .NET Framework includes a new class named System.Windows.Shell.TaskBarItemInfo
that enables you to create a taskbar item for your WPF application.
To create a taskbar item, you create a TaskBarItemInfo
object and assign it to the Window.TaskBarItemInfo
property of your form. When your application runs on Windows 7, you will see your taskbar item for your application. This is covered in the topic “TaskbarItemInfo Class”, which also describes how to do several cool taskbar tricks.
- Doc D
Dear Doc Detective,
I have an application that was originally upgraded from Visual Basic 6.0 several years ago. After opening the app in Visual Studio 2010 and changing it to use the latest version of the .NET Framework, I'm seeing warnings in the error list.
Basically the errors state that various members of the Microsoft.VisualBasic.Compatibility.VB6
namespace are obsolete. Does this mean that I've reached a dead-end with my upgraded application? Please tell me that I don't have to rewrite my application.
- Troubled in Troutdale
Dear Troubled,
You don't have to rewrite your application. The warning is somewhat benign - your application will still work just fine in Visual Studio 2010. What the warning actually means is that the Compatibility
namespace will not be included in some future version of the .NET Framework.
While this may sound ominous, the actual impact is minimal. If the namespaces are removed from the framework, it simply means that you might need to
package the assembly that contains them and deploy it with your application.
By the time this actually happens, your application will probably be more than ten years old. At that point, rewriting your application might not be such a bad idea - but you still won't have to.
- Doctor D
Doc's Doc Tip of the Day
Do you prefer to use local Help, but feel like you are missing out on the latest content unless you go online? The new Help system in Visual Studio 2010 can solve your dilemma with the ability to update your offline content.
The Help Library Manager, accessed via the Help menu, includes an option to check for updates online. The Help library is divided into numerous smaller “books” - if a newer version of a book exists, it will download in the background and replace your local version on the fly.
Found a topic in Help that doesn't help? Tell the Visual Studio documentation team about it by clicking on the “Send feedback” link in local Help topics, or the “Click to rate and give feedback” link in online Help.
URLs
http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid(VS.100).aspx
http://msdn.microsoft.com/en-us/library/ee340709(VS.100).aspx
http://msdn.microsoft.com/en-us/library/17k74w0c(VS.100).aspx
http://msdn.microsoft.com/en-us/library/system.windows.shell.taskbariteminfo(VS.100).aspx