Try the following code placed into a code module. As coded you need your
main form to be named "frmMainForm". Note the line
MakeSystemStyle(mMainForm) will go through each control and set FlatStyle =
True which needs to be done for the XP look to work as expected. Hope this
helps.
BTW SetProperty is not mine, it came from a programmer who I can not
remember his name but he is one of the gurus here.
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Module StartUp
Friend mMainForm As frmMainForm
Public Class DOR
Inherits System.Windows.Forms.Form
<System.STAThread()> Public Shared Sub Main()
'
' Permit Visual XP Styling
'
System.Windows.Forms.Application.EnableVisualStyles()
'
' Required for implementing XP Styling...as per above has a bug in
..NET 1.1
'
Application.DoEvents()
'
' Set up access via the Class Program below which allows us to
access
' items on the frmMainForm from a child form.
'
mMainForm = New frmMainForm
mMainForm.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen
'
' MakeSystemStyle in short goes through "every" control on the
passed form
' and if a control has the 'FlatStyle' property it is set to
[System style]
' which in turns permits XP styling coupled with The first lin in
the procedure.
'
MakeSystemStyle(mMainForm)
'
' Fire up the main form
'
System.Windows.Forms.Application.Run(mMainForm)
Application.DoEvents()
End Sub
End Class
Public Class Program
Public Shared ReadOnly Property MainForm() As frmMainForm
Get
Return mMainForm
End Get
End Property
Public Shared ReadOnly Property ApplicationPath() As String
Get
Return Application.StartupPath()
End Get
End Property
End Class
Private Function SetProperty(ByVal objUnknown As Object, ByVal
propertyName As String, ByVal ObjectValue As Object) As Boolean
Try
Dim PropInfo As System.Reflection.PropertyInfo =
objUnknown.GetType().GetProperty(propertyName)
If PropInfo Is Nothing Then Return False
ObjectValue = Convert.ChangeType(ObjectValue,
PropInfo.PropertyType)
PropInfo.SetValue(objUnknown, ObjectValue, Nothing)
Return True
Catch
Return False
End Try
End Function
Public Sub MakeSystemStyle(ByVal ParamArray TheForm() As Control)
Dim ControlItem As Control
For Each ControlItem In TheForm
SetProperty(ControlItem, "FlatStyle",
System.Windows.Forms.FlatStyle.System)
Dim c As Control
For Each c In ControlItem.Controls
MakeSystemStyle(c)
Next
Next
End Sub
End Module