[VB.NET] แจกโค้ดการใช้งาน Ribbon Control Advance ของฟรีจากค่าย Syncfusion
http://www.g2gnet.com/webboard/images/vbnet/ribbonadv0.jpghttp://www.g2gnet.com/webboard/images/vbnet/ribbonadv1.jpg
http://www.g2gnet.com/webboard/images/vbnet/ribbonadv2.jpg
http://www.g2gnet.com/webboard/images/vbnet/ribbonadv3.jpg
http://www.g2gnet.com/webboard/images/vbnet/ribbonadv4.jpg
http://www.g2gnet.com/webboard/images/vbnet/ribbonadv5.jpg
โค้ดการใช้งาน Ribbon Control Advance ของค่าย Syncfusion (ฟอร์มหลัก MDI)...
Imports Syncfusion.Windows.Forms.Tools
Public Class frmMainRibbon
Private Sub frmMainRibbon_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Me.Dispose()
GC.SuppressFinalize(Me)
Application.Exit()
End Sub
Private Sub frmMainRibbon_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'// Run Time
With Me.RibbonControlAdv1
'.AutoLayoutToolStrip = False
.MenuButtonEnabled = False
.MenuButtonVisible = False
.QuickPanelVisible = False
.ScaleMenuButtonImage = False
.ShowContextMenu = True ' False
.ShowLauncher = False
.ShowMinimizeButton = True' false
.ShowQuickItemsDropDownButton = False
.ShowRibbonDisplayOptionButton = False ' True
End With
Me.RibbonControlAdv1.IsFormManager = False
'// Set Default.
Call Office2016ToolStripMenuItem_Click(sender, e)
'// StatusStrip
ToolStripStatusLabel1.Text = ""
ToolStripStatusLabel2.Text = ""
'// Refresh every 1 Min. (1000 ms = 1 sec.)
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
'// Office 2016
Private Sub Office2016ToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles Office2016ToolStripMenuItem.Click
Me.RibbonControlAdv1.RibbonStyle = Syncfusion.Windows.Forms.Tools.RibbonStyle.Office2016
Me.Office2016ToolStripMenuItem.Checked = True
'//
Me.Office2007ToolStripMenuItem.Checked = False
Me.Office2010ToolStripMenuItem.Checked = False
Me.Office2013ToolStripMenuItem.Checked = False
Me.TouchToolStripMenuItem.Checked = False
End Sub
'// Toucj Tool
Private Sub TouchToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles TouchToolStripMenuItem.Click
Me.RibbonControlAdv1.RibbonStyle = Syncfusion.Windows.Forms.Tools.RibbonStyle.TouchStyle
Me.TouchToolStripMenuItem.Checked = True
'//
Me.Office2007ToolStripMenuItem.Checked = False
Me.Office2010ToolStripMenuItem.Checked = False
Me.Office2013ToolStripMenuItem.Checked = False
Me.Office2016ToolStripMenuItem.Checked = False
End Sub
'// Office 2007
Private Sub Office2007ToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles Office2007ToolStripMenuItem.Click
Me.RibbonControlAdv1.RibbonStyle = Syncfusion.Windows.Forms.Tools.RibbonStyle.Office2007
Office12ColorTable.ApplyManagedColors(Me, Color.Red)
Me.Office2007ToolStripMenuItem.Checked = True
'//
Me.Office2010ToolStripMenuItem.Checked = False
Me.Office2013ToolStripMenuItem.Checked = False
Me.Office2016ToolStripMenuItem.Checked = False
Me.TouchToolStripMenuItem.Checked = False
End Sub
'// Office 2010
Private Sub Office2010ToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles Office2010ToolStripMenuItem.Click
Me.RibbonControlAdv1.RibbonStyle = Syncfusion.Windows.Forms.Tools.RibbonStyle.Office2010
Me.Office2010ToolStripMenuItem.Checked = True
'//
Me.Office2007ToolStripMenuItem.Checked = False
Me.Office2013ToolStripMenuItem.Checked = False
Me.Office2016ToolStripMenuItem.Checked = False
Me.TouchToolStripMenuItem.Checked = False
End Sub
'// Office 2013
Private Sub Office2013ToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles Office2013ToolStripMenuItem.Click
Me.RibbonControlAdv1.RibbonStyle = Syncfusion.Windows.Forms.Tools.RibbonStyle.Office2013
Me.Office2013ToolStripMenuItem.Checked = True
'//
Me.Office2007ToolStripMenuItem.Checked = False
Me.Office2010ToolStripMenuItem.Checked = False
Me.Office2016ToolStripMenuItem.Checked = False
Me.TouchToolStripMenuItem.Checked = False
End Sub
Private Sub ToolStripButton1_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton1.Click
'MessageBox.Show("You Click me.")
With frmFirst
.MdiParent = Me
.TopMost = True
.Show()
End With
End Sub
Private Sub tsbExit_Click(sender As Object, e As System.EventArgs) Handles tsbExit.Click
Me.Close()
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Me.ToolStripStatusLabel2.Text = "Date-Time: " & Format(Now(), "dd/MM/yyyy HH:mm:ss")
End Sub
End Class
ตัวอย่างโค้ดฟอร์มลูกที่ต้องเปิดใน MDI (Multiple Document Interface) ...
Imports System.Data
Public Class frmFirst
Private Sub frmFirst_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Me.Dispose()
GC.SuppressFinalize(Me)
End Sub
Private Sub frmFirst_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Dock = DockStyle.Fill
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.MinimizeBox = False
Me.MaximizeBox = False
Me.ControlBox = False
'//
Call SetupGridView(dgvData)
dgvData.DataSource = GetDataTable()
End Sub
Private Sub SetupGridView(ByRef DGV As DataGridView)
With DGV
.RowHeadersVisible = True
.AllowUserToAddRows = False
.AllowUserToDeleteRows = False
.AllowUserToResizeRows = False
.MultiSelect = False
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
.ReadOnly = True
'// Data rows
.Font = New Font("Tahoma", 10)
.RowTemplate.MinimumHeight = 27
.RowTemplate.Height = 27
'// Column Header
.ColumnHeadersHeight = 30
.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
'// Autosize Column
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
'// Even-Odd Color
.AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue
.DefaultCellStyle.SelectionForeColor = Color.White
'// Header
With .ColumnHeadersDefaultCellStyle
.BackColor = Color.Navy
.ForeColor = Color.White
.Font = New Font(DGV.Font, FontStyle.Bold)
End With
End With
End Sub
Function GetDataTable() As Data.DataTable
Dim dt As New Data.DataTable
' / เพิ่มหลัก (Columns) หรือฟิลด์ จำนวน 6 หลัก
With dt
.Columns.Add("EmployeePK", GetType(Integer))
.Columns.Add("EmployeeID", GetType(String))
.Columns.Add("EmployeeName", GetType(String))
.Columns.Add("Position", GetType(String))
.Columns.Add("Department", GetType(String))
.Columns.Add("HireDate", GetType(Date))
End With
' / เพิ่มรายการข้อมูล (Record) เรียงตามลำดับฟิลด์
With dt
.Rows.Add("1", "EMP00001", "นายทองก้อน ทับทิมกรอบ", "Managing Director", "Management", "01/01/2555")
.Rows.Add("2", "EMP00002", "นายบุญห่อ พ่อรวย", "ช่างซ่อมบำรุง", "Technical", "01/06/2555")
.Rows.Add("3", "EMP00003", "นางสาวกุ๊กกิ๊ก น่ารักที่สุด", "เลขา", "Management", "25/02/2555")
.Rows.Add("4", "EMP00004", "นางบัวผัน ฝันเฟื่อง", "หัวหน้าบัญชี", "บัญชี", "11/11/2555")
.Rows.Add("5", "EMP00005", "หนูมาลี มีลูกแมวเหมียว", "ธุรการ", "ธุรการ", "13/04/2555")
End With
'// Hidden Column 0 of DataTable
dt.Columns(0).ColumnMapping = MappingType.Hidden
Return dt
End Function
Private Sub itemAdd_Click(sender As System.Object, e As System.EventArgs) Handles itemAdd.Click
MessageBox.Show("You Click me for Add New Data.")
End Sub
Private Sub itemExit_Click(sender As System.Object, e As System.EventArgs) Handles itemExit.Click
Me.Close()
End Sub
End Class
ดาวน์โหลดโค้ดฉบับเต็ม VB.NET 2010 (.Net Framework 4.0+) ได้ที่นี่ ...
ขอบคุณครับจารย์ ขอบคุณมากครับ ขอบคุณครับอาจารย์ thank you , sir.
หน้า:
[1]