T
TC
I'm a programmer, but I'm not a UI guy. I'm using Visual Studio 2005
to write a new application and I'm dealing with "Visual Styles" for
the first time. From what I can figure, when you enable visual styles,
you're telling NET to ignore some formatting commands and instead to
format controls according to the system settings. That's fine, except
that the feature seems to be poorly documented and inconsistent.
Right now, I'm trying to create a SplitContainer control that has a
TreeView in Panel1 and a UserControl in Panel2. I've set the border
style for both the TreeView and UserControl to Fixed3D. With visual
styles enabled, that makes the TreeView have a stylish thin blue
border, and it makes the UserControl have a 3D border. I can't find
any way to keep visual styles enabled and to make the two controls
match (i.e. either give the TreeView a 3D border or to give the
UserControl a stylish border).
My conclusion is that only some controls use the visual styles, so my
options are to 1) produce an application with mismatched visual
elements; 2) figure out which controls support visual styles and use
only those controls; 3) use third-party controls; or 4) don't use
visual styles.
I'd like to hear from programmers who have experience building user
interfaces with NET 2.0. Is my analysis correct, or am I missing
something?
By the way, I've posted below the code I used to determine that
TreeView, ListView, and TextBox support visual styles, but Panel,
UserControl, and FlowLayoutPanel do not.
-TC
Imports System.Windows.Forms
Public Class Form1
Inherits Form
Public Sub New()
Application.EnableVisualStyles()
Dim TreeView1 As New TreeView
TreeView1.BorderStyle = BorderStyle.Fixed3D
TreeView1.SetBounds(25, 25, 75, 75)
Me.Controls.Add(TreeView1)
Dim ListView1 As New ListView
ListView1.BorderStyle = BorderStyle.Fixed3D
ListView1.SetBounds(125, 25, 75, 75)
Me.Controls.Add(ListView1)
Dim TextBox1 As New TextBox
TextBox1.BorderStyle = BorderStyle.Fixed3D
TextBox1.SetBounds(225, 25, 75, 75)
Me.Controls.Add(TextBox1)
Dim Panel1 As New Panel
Panel1.BorderStyle = BorderStyle.Fixed3D
Panel1.SetBounds(25, 125, 75, 75)
Me.Controls.Add(Panel1)
Dim UserControl1 As New UserControl
UserControl1.BorderStyle = BorderStyle.Fixed3D
UserControl1.SetBounds(125, 125, 75, 75)
Me.Controls.Add(UserControl1)
Dim FlowLayoutPanel1 As New System.Windows.Forms.FlowLayoutPanel
FlowLayoutPanel1.BorderStyle = BorderStyle.Fixed3D
FlowLayoutPanel1.SetBounds(225, 125, 75, 75)
Me.Controls.Add(FlowLayoutPanel1)
Me.ClientSize = New System.Drawing.Size(325, 225)
End Sub
End Class
to write a new application and I'm dealing with "Visual Styles" for
the first time. From what I can figure, when you enable visual styles,
you're telling NET to ignore some formatting commands and instead to
format controls according to the system settings. That's fine, except
that the feature seems to be poorly documented and inconsistent.
Right now, I'm trying to create a SplitContainer control that has a
TreeView in Panel1 and a UserControl in Panel2. I've set the border
style for both the TreeView and UserControl to Fixed3D. With visual
styles enabled, that makes the TreeView have a stylish thin blue
border, and it makes the UserControl have a 3D border. I can't find
any way to keep visual styles enabled and to make the two controls
match (i.e. either give the TreeView a 3D border or to give the
UserControl a stylish border).
My conclusion is that only some controls use the visual styles, so my
options are to 1) produce an application with mismatched visual
elements; 2) figure out which controls support visual styles and use
only those controls; 3) use third-party controls; or 4) don't use
visual styles.
I'd like to hear from programmers who have experience building user
interfaces with NET 2.0. Is my analysis correct, or am I missing
something?
By the way, I've posted below the code I used to determine that
TreeView, ListView, and TextBox support visual styles, but Panel,
UserControl, and FlowLayoutPanel do not.
-TC
Imports System.Windows.Forms
Public Class Form1
Inherits Form
Public Sub New()
Application.EnableVisualStyles()
Dim TreeView1 As New TreeView
TreeView1.BorderStyle = BorderStyle.Fixed3D
TreeView1.SetBounds(25, 25, 75, 75)
Me.Controls.Add(TreeView1)
Dim ListView1 As New ListView
ListView1.BorderStyle = BorderStyle.Fixed3D
ListView1.SetBounds(125, 25, 75, 75)
Me.Controls.Add(ListView1)
Dim TextBox1 As New TextBox
TextBox1.BorderStyle = BorderStyle.Fixed3D
TextBox1.SetBounds(225, 25, 75, 75)
Me.Controls.Add(TextBox1)
Dim Panel1 As New Panel
Panel1.BorderStyle = BorderStyle.Fixed3D
Panel1.SetBounds(25, 125, 75, 75)
Me.Controls.Add(Panel1)
Dim UserControl1 As New UserControl
UserControl1.BorderStyle = BorderStyle.Fixed3D
UserControl1.SetBounds(125, 125, 75, 75)
Me.Controls.Add(UserControl1)
Dim FlowLayoutPanel1 As New System.Windows.Forms.FlowLayoutPanel
FlowLayoutPanel1.BorderStyle = BorderStyle.Fixed3D
FlowLayoutPanel1.SetBounds(225, 125, 75, 75)
Me.Controls.Add(FlowLayoutPanel1)
Me.ClientSize = New System.Drawing.Size(325, 225)
End Sub
End Class