Dave Burke : Freelance .NET Web Developer specializing in Online Communities

DevTeach2004 : .NET Windows Tips and Tricks


.NET Windows Tips and Tricks. 
Cathi Gero.
NET250.

These session notes serve primarily to share the content of the session and as a reference for me.  They may also provide some value to those interested in the session topics. Some of the information found in these notes may be inaccurate due to my typing errors or a lack of understanding of the subject matter. DevTeach policy is that session material is available online to registered attendees only, so I cannot respond to any requests for session PPTs or source.

Custom-drawn controls with GDI+.  Use the DrawEventArgs properties.  Combo boxes, list boxes.

Use Data to Control the User INterface
- data binding can be used for more than just data
- can bind almost any property to almost any value

Binding example: this.Panel1.DataBindings.Add("Visible", CheckBox1, "Checked");

Binding BackColorBinding = new Binding("BackColor", TextBox1, "Text")
BackColorBinding.Format = [private method to convert string to color.  If known, color passed back to be bound.]

Expose protected info with inheritance
- inherit from the control and expose the functionality as public.
- create a custom control to add to toolbox

Example, two scrolling datagrids moving in sync.  Scroll method in datagrid. VertScrollBar property.  VertScrollBar is a protected property, compiler flag.  Create custom function inherits from DataGrid (MyDataGrid:DataGrid).  Replace base datagrid references with MyDataGrid.
Step one, scroll bar moves, but displayed row does not.  Need to use GridVScrolled (property) over-ridden.

I saw Chris Kinsman do this very thing over a year ago at a VTDotNet meeting.  Chris was a great presenter!

Enhance the look of your Application.

Take advantage of Windows XP Visual Styles.  Application.EnableVisualStyles(); before calling first form.  Gotcha.  GroupBox, Button, CheckBox, RadioButton, etc require the FlatStyle property to System.

Create Transparent Regions.  Use a background image and set the transparency color to a color in the imiage.  Requires 24-bit OR LESS for this to work.  (Not so valuable tip in that case, I would say...)

Create Non-Rectangular Forms

Form Fading on Close.  Add timer, on close enable timer and decrease opacity property.

Avoid Work when Drawing Controls
- Inherit from existing contgrols
- create userconttrol and its design surface
- draw yourself using GDI+
- ControlPaint class to create modified versions of standard controls

DataGrid Formatting with GridTableStylesCollection.  Each GridTableStyles object has a GridTableStylesCollection associated with it.  TableStyle Collection wizard.

Limit Editing in DataGrid.  DataView provides AllowEdit, AllowNew, and AllowDelete properties

Ensure thread safe apps.  Windows Forms apps can crash if form performs function from different thread.  Example of retrieving Dilbert from webservice.  Create Delegate and Invoke delegate to the web service.

Using the PropertyGrid.  Can use the property grid inside of your applications.  Sweet.  In the TestPropertyGrid_Load, create a [[Serializeable()] class with public properties, Description and Categories.  Inside the propertygrid form, the settings are persisted.  Check out article on MSDN on this.  URL in PPT.

Summary: using the property box in apps was a great tip.  Otherwise, not real helpful in the day-to-day.  Presenter did a good job, well prepared and knowledgeable. 8 out of 10.

Comments (0) | Post RSS RSS comment feed

Posted on 6/23/2004 9:39:00 PM by Dave Burke
Categories:
Tags: no tags for this post

Related posts


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke