Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET 4.5
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Amazon Web Services
Analysis Services
Android
Architecture
Arduino
ASP .NET Web API
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
BDD
Big Data
Bing
BizTalk
Book Excerpts
Build and Deploy
Business Intelligence
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE Framework Info - non Technical
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Debugger
Design Patterns
Development Process
Display Technologies
Distributed Computing
Document Database
DotNetNuke
DSL
Dynamic Languages
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
HTML 5
Internet Explorer 8.0
Interviews
IOS
iPhone
Iron Ruby
Java
Java Script
JavaScript
jQuery
JSON
Lightswitch
LINQ
Linux
LUA
Mac OS X
MDX
Messaging
Metro
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
MVVM
MySQL
Network
NHibernate
node.js
NOSQL
Nuget
Object Oriented Development
Objective C
Odata
OLAP
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
PHP
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Prolog
Python
Q&A
Rails
Rake
Razor
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Scheme
Search
Security
Services
SharePoint
SignalR
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2012
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
TFS
Tips
TypeScript
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 11
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio 2011
Visual Studio 2012
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WebMatrix
WF
Whitepapers
Windows 7
Windows 8
Windows Azure
Windows Live
Windows Phone 7
Windows Phone SDK
Windows Server
Windows Vista
WinForms
WinRT
Workflow
WPF
XAML
Xiine Documentation
XML
XNA
XSLT



LearnNow


XAMALOT
 


Sharepoint TechCon

Reader rating:
Article source: CoDe (2008 Nov/Dec)

Ask the Doc Detective


Doc Detective

Finding what you need in the Microsoft® Visual Studio® 2008 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).

Dear Doc Detective,

I need to prevent my users from running more than one copy of my application at a time. Is there an easy way to tell if they are starting a second copy, then stop them and display a message?

-Stuck in Stuckeyville

Dear Stuck,

There is more than one way, and whether it's easy depends on the language that you are using.

If you're using Visual Basic, you can simply set the Make Single Instance Application project option as described in "How to: Specify Instancing Behavior for an Application". When the user tries to launch a second instance, the first instance will be brought to the foreground instead.

Once you've set the property, a new StartupNewInstance event is fired when the user tries to launch the application-you can add code here to display a message. This is described in the topic "My.Application.StartupNextInstance Event".

If you aren't using Visual Basic, you can still check for a running instance of the application by calling the GetProcessesByName method in the System.Diagnostics namespace-it’s just a little harder. Just check the array returned by GetProcessesByName to see if it contains your application’s name, and if so, prevent the new instance from launching.

-Doc D

Dear Doc Detective,

I'm running into issues with the behavior of a transparent label control on top of a picture box. When adding a transparent label control to form with a background image, the label displays correctly and shows the background.

When you add a picture box control and add another transparent label on top of said picture box, the transparent label control on top of a picture box does not display correctly-the background doesn't show through. What's up with that?

-Miffed in Mayberry

Dear Miffed,

What you are seeing is a known limitation of Windows Forms. Labels are transparent to their container or parent-not to the control underneath them. Windows does not support transparency so Windows Forms fakes it by painting the parent’s background inside the bounds of the label.

Fortunately there are a couple of ways to work around this, neither of which involves a label. The first would be to draw the text yourself in the parent form’s Paint event. For information on drawing text, look for the topic "How to: Draw Text at a Specified Location".

The other solution is to remove the PictureBox control and draw its contents in the Paint event. The topic "How to: Load and Display Bitmaps" explains how to draw an image on a form.

Either solution will allow your floating label to have the correct transparent behavior.

-Doc Detective

Dear Doc Detective,

I’m having trouble printing a report based on a Grid control. I've written the logic for printing using a PrintDocument, but the one thing I can't figure out is how to wrap the text. If the text in a given cell gets too large, it's extending the LayoutRectangle, which isn't what I want.

-Sprung in Springfield

Dear Sprung,

If I understand you correctly, you are trying to print the contents of a data grid (DataGridView) control and the LayoutRectangle is changing in size based on the amount of text in a given cell. If you want the LayoutRectangle size to remain constant, you can do so by changing the StringFormat settings. The article "Printing Reports in Windows Forms" describes this in detail.

-The Doc

Dear Doc Detective,

I have a problem with a MDI application that I'm working on. I have placed an image in a picture box on the MDI parent form, but when I add child forms at run time, they appear hidden behind the picture box.

This obviously isn't the behavior that I want. How can I make the child forms appear on top?

-Screaming in Scranton

Dear Screaming,

Believe it or not, this is the way it was designed to work. Any controls that you place on a MDI container form will appear in front of the Child forms. In general you shouldn't put controls on a MDI parent form, but there are cases where it is useful-for example, adding a StatusBar to the bottom of the form.

To display a picture on the MDI parent, use the BackgroundImage property of the form itself instead of using a PictureBox control-the BackgroundImage will appear behind the Child forms. While this isn't specifically covered in the docs, you can learn more about MDI in the topic "Multiple-Document Interface (MDI) Applications". Now you can come out of hiding.

-Doctor D

Doc’s Doc Tip of the Day

Ever notice that sometimes when you press F1 in the Code Editor you get the wrong result? A reader reported a discrepancy when trying to get help on File.Open-placing the cursor on the word Open and pressing F1 brought up the right topic, but highlighting Open and pressing F1 brought up a SQLConnection,Open topic.

While this behavior may seem odd, it's actually by design. The F1 logic looks at the current position of the cursor, uses that word and any surrounding words to establish context, and then it does the F1 lookup.

If you highlight the word, it doesn’t look for context-it just finds the first instance of that keyword and displays the topic. In this case, the SQLConnection.Open topic has a higher priority than the File.Open topic, so it was found first.

If you highlight both File and Open, it “might” have enough context to find the right topic, but if there is more than one File.Open topic you may still get the wrong one. Bottom line-don’t highlight the keyword and you’ll be fine.

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.

"
Have a question for the Doc? Send your questions for future columns to me at docdetec@microsoft.com.
"


How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
3 out of 5

3 people have rated this article.

Instantly Search Terabytes Of Text
“Lightning Fast”
– Redmond Mag
“Covers all data
sources” – eWeek
25+ fielded & full-text search options
dtSearch’s own document filters highlight hits in popular file types
Web Spider supports static & dynamic data
APIs for .NET, Java, C++, SQL, etc.
Win / Linux (64-bit & 32-bit)
www.dtSearch.com
 

      AppsWorld Europe

 

SSWUG