ListView Header 外观扁平化
ListView Header apperance flat
希望你们一切都好,过得好。
我在列表视图中遇到一个问题。我有一些 headers 是列表视图,它们看起来很平,而不是根据 windows 7 主题。
请参阅附件图片。
由于您从 Sub Main
启动您的应用程序,因此您没有使用自动启用视觉样式的 VB "Application Framework"。这很容易修复:
Public Sub Main()
' use this before any WinForms elements are
' created or referenced!
Application.EnableVisualStyles() ' to add
'... your other code
Application.Run(New MainForm) ' start up form
End Sub
为什么这些问题的答案总是涉及Application.Run()
?不需要。 DoEvents
也不是。以下是以 Sub Main() 开头的实用表单应用程序的基础。它涉及一个用户设计的实例化和显示的表单,并在表单关闭后利用包对象将来自所述表单的响应发送回调用子例程。
Option Strict
Public Module EntryPoint
Public Sub Main()
'Optional, if you want the Vista/Windows7 theme on your controls
Application.EnableVisualStyles()
'Show a form
dim response As New MyCustomPack
Using form As New MyCustomForm(response)
form.ShowDialog()
End Using
'Do something with the response
System.Windows.Forms.MessageBox.Show(String.Format("The response is {0}", response.Value))
'The program now ends
End Sub
End Module
Public Class MyCustomForm
Inherits System.Windows.Forms.Form
Private WithEvents _CtrBtnChoice1 As System.Windows.Forms.Button = Nothing
Private WithEvents _CtrBtnChoice2 As System.Windows.Forms.Button = Nothing
Private _Response As MyCustomPack = Nothing
Public Sub New(ByRef Out_Response As MyCustomPack)
_Response = Out_Response
End Sub
Private Sub Form_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Setup form controls here
_CtrBtnChoice1 = New System.Windows.Forms.Button
_CtrBtnChoice2 = New System.Windows.Forms.Button
With _CtrBtnChoice1
'Set button size, location, text, etc
End With
With _CtrBtnChoice2
'Set button size, location, text, etc
End With
End Sub
Private Sub _CtrBtnChoice1_Click(sender As Object, e As System.EventArgs) Handles _CtrBtnChoice1.Click
_Response.Value = 11111
Me.Close()
End Sub
Private Sub _CtrBtnChoice2_Click(sender As Object, e As System.EventArgs) Handles _CtrBtnChoice2.Click
_Response.Value = 22222
Me.Close()
End Sub
End Class
Public Class MyCustomPack
Public Value As Integer
End Class
希望你们一切都好,过得好。
我在列表视图中遇到一个问题。我有一些 headers 是列表视图,它们看起来很平,而不是根据 windows 7 主题。
请参阅附件图片。
由于您从 Sub Main
启动您的应用程序,因此您没有使用自动启用视觉样式的 VB "Application Framework"。这很容易修复:
Public Sub Main()
' use this before any WinForms elements are
' created or referenced!
Application.EnableVisualStyles() ' to add
'... your other code
Application.Run(New MainForm) ' start up form
End Sub
为什么这些问题的答案总是涉及Application.Run()
?不需要。 DoEvents
也不是。以下是以 Sub Main() 开头的实用表单应用程序的基础。它涉及一个用户设计的实例化和显示的表单,并在表单关闭后利用包对象将来自所述表单的响应发送回调用子例程。
Option Strict
Public Module EntryPoint
Public Sub Main()
'Optional, if you want the Vista/Windows7 theme on your controls
Application.EnableVisualStyles()
'Show a form
dim response As New MyCustomPack
Using form As New MyCustomForm(response)
form.ShowDialog()
End Using
'Do something with the response
System.Windows.Forms.MessageBox.Show(String.Format("The response is {0}", response.Value))
'The program now ends
End Sub
End Module
Public Class MyCustomForm
Inherits System.Windows.Forms.Form
Private WithEvents _CtrBtnChoice1 As System.Windows.Forms.Button = Nothing
Private WithEvents _CtrBtnChoice2 As System.Windows.Forms.Button = Nothing
Private _Response As MyCustomPack = Nothing
Public Sub New(ByRef Out_Response As MyCustomPack)
_Response = Out_Response
End Sub
Private Sub Form_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Setup form controls here
_CtrBtnChoice1 = New System.Windows.Forms.Button
_CtrBtnChoice2 = New System.Windows.Forms.Button
With _CtrBtnChoice1
'Set button size, location, text, etc
End With
With _CtrBtnChoice2
'Set button size, location, text, etc
End With
End Sub
Private Sub _CtrBtnChoice1_Click(sender As Object, e As System.EventArgs) Handles _CtrBtnChoice1.Click
_Response.Value = 11111
Me.Close()
End Sub
Private Sub _CtrBtnChoice2_Click(sender As Object, e As System.EventArgs) Handles _CtrBtnChoice2.Click
_Response.Value = 22222
Me.Close()
End Sub
End Class
Public Class MyCustomPack
Public Value As Integer
End Class