ชุมชนคนรักภาษาเบสิค - Visual Basic Community

 ลืมรหัสผ่าน
 ลงทะเบียน
ค้นหา
ดู: 3138|ตอบกลับ: 0

[VB.NET] การใช้งาน GroupBar ของฟรีใน Syncfusion Community

[คัดลอกลิงก์]

311

กระทู้

502

โพสต์

6072

เครดิต

ผู้ดูแลระบบ

ทองก้อน ทับทิมกรอบ

Rank: 9Rank: 9Rank: 9

เครดิต
6072




ย้ำอีกทีน่ะครับว่า Syncfusion Community เป็นของฟรีที่เต็มไปด้วย Control หรือ Component ที่น่าใช้งานอยู่มากมายหลายตัว และหนึ่งในนั้นก็คือ GroupBar ซึ่งนำมาใช้ประโยชน์ด้วยการจัดหมวดหมู่กลุ่ม Control อีกทีหนึ่งได้ค่อนข้างดีทีเดียว ... (Download Syncfusion Community Edition)


การเรียกใช้งาน Syncfusion โดยเลือก Reference ตัวหลัก 2 ตัวนี้ ...



หน้าจอการออกแบบ (Design Time)


มาดูโค้ดกันเถอะ ...
  1. ' / -------------------------------------------------------------------------------
  2. ' / Developer : Mr.Surapon Yodsanga (Thongkorn Tubtimkrob)
  3. ' / eMail : thongkorn@hotmail.com
  4. ' / URL: http://www.g2gnet.com (Khon Kaen - Thailand)
  5. ' / Facebook: https://www.facebook.com/g2gnet (For Thailand)
  6. ' / Facebook: https://www.facebook.com/commonindy (Worldwide)
  7. ' / More Info: http://www.g2gnet.com/webboard
  8. ' /
  9. ' / Purpose: Using GroupBar of Syncfusion Community.
  10. ' / Microsoft Visual Basic .NET (2010)
  11. ' /
  12. ' / This is open source code under @CopyLeft by Thongkorn Tubtimkrob.
  13. ' / You can modify and/or distribute without to inform the developer.
  14. ' / -------------------------------------------------------------------------------

  15. Public Class frmGroupBar

  16.     Private Sub frmGroupBar_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  17.         Me.CenterToScreen()
  18.         '/ MessageBox.Show(AppPath);
  19.         Dim MyPath As String = Application.StartupPath.ToLower
  20.         MyPath = MyPath.Replace("\bin\debug", "").Replace("\bin\release", "").Replace("\bin\x86\debug", "")
  21.         '// If not found folder then put the \ (BackSlash) at the end.
  22.         If Microsoft.VisualBasic.Right(MyPath, 1) <> Chr(92) Then MyPath = MyPath & Chr(92)
  23.         Dim strPathImage As String = MyPath & "images"
  24.         '//
  25.         Me.GroupBar1.ForeColor = Color.Black
  26.         Me.GroupBar1.Font = New Font("Tahoma", 10, FontStyle.Bold)
  27.         '// Acquire the DataTable instance.
  28.         Dim table As DataTable = GetTable()
  29.         Dim row As DataRow
  30.         Dim img As String
  31.         '/ Load data @RunTime
  32.         Dim Rec As Integer = 0
  33.         Dim myButtons = { _
  34.             btnBurger1, btnBurger2, btnBurger3, btnBurger4, btnBurger5, btnBurger6, btnBurger7, _
  35.             btnSmall1, btnSmall2, btnSmall3, btnMedium1, btnMedium2, btnMedium3, btnLarge1, btnLarge2, btnLarge3 _
  36.             }
  37.         For Each btn In myButtons
  38.             row = table.Rows(Rec)
  39.             With btn
  40.                 '// ใช้คุณสมบัติ Tag เก็บค่า Primary Key
  41.                 .Tag = row("PK")
  42.                 '// ใช้คุณสมบัติ Text เก็บค่า Description
  43.                 .Text = row("Description")
  44.                 img = strPathImage & row("Picture")
  45.                 .BackgroundImage = New System.Drawing.Bitmap(img)
  46.             End With
  47.             '// Force events handler.
  48.             AddHandler btn.Click, AddressOf ClickButton
  49.             Rec += 1
  50.         Next
  51.     End Sub

  52.     '// Click Button event, get the text of button
  53.     Public Sub ClickButton(ByVal sender As Object, ByVal e As System.EventArgs)
  54.         Dim btn As Button = sender
  55.         '// หากนำไปใช้งานจริง ข้อมูลของตัวสินค้าจะถูกเรียกมาจากตารางข้อมูล
  56.         '// Acquire the DataTable instance.
  57.         Dim table As DataTable = GetTable()
  58.         'Search DataTable by string DataType
  59.         Dim oRow() As DataRow = table.Select("PK = " & btn.Tag)
  60.         MessageBox.Show("You choose: " & btn.Text & vbCrLf & "Price: " & CDbl(oRow(0)("PriceCash")) & " Baht.")
  61.     End Sub

  62.     '// จำลองเป็นตารางข้อมูล (Table)
  63.     Function GetTable() As DataTable
  64.         ' Generate a new DataTable.
  65.         ' ... Add columns.
  66.         Dim table As DataTable = New DataTable
  67.         table.Columns.Add("PK", GetType(Integer))
  68.         table.Columns.Add("Description", GetType(String))
  69.         table.Columns.Add("PriceCash", GetType(Double))
  70.         table.Columns.Add("Quantity", GetType(Integer))
  71.         table.Columns.Add("Picture", GetType(String))
  72.         ' ... Add rows.
  73.         table.Rows.Add(1, "Classic Checken", "50.00", "1", "BurgerChicken.png")
  74.         table.Rows.Add(2, "Mexicana", "100.00", "1", "BurgerMexicana.png")
  75.         table.Rows.Add(3, "Lemon Shrimp", "150.00", "1", "BurgerLemonShrimp.png")
  76.         table.Rows.Add(4, "Bacon", "200.00", "1", "BurgerBacon.png")
  77.         table.Rows.Add(5, "Spicy Shrimp", "250.00", "1", "BurgerSpicyShrimp.png")
  78.         table.Rows.Add(6, "Tex Supreme", "300.00", "1", "BurgerTexSupreme.png")
  79.         table.Rows.Add(7, "Fish", "350.00", "1", "BurgerFish.png")
  80.         '//
  81.         table.Rows.Add(101, "Pepsi Small", "10.00", "1", "PepsiCan.png")
  82.         table.Rows.Add(102, "Coke Small", "15.00", "1", "CocaColaCan.png")
  83.         table.Rows.Add(103, "7Up Small", "20.00", "1", "7UpCan.png")
  84.         table.Rows.Add(104, "Pepsi Medium", "25.00", "1", "PepsiCan.png")
  85.         table.Rows.Add(105, "Coke Medium", "30.00", "1", "CocaColaCan.png")
  86.         table.Rows.Add(106, "7Up Medium", "45.00", "1", "7UpCan.png")
  87.         table.Rows.Add(107, "Pepsi Large", "50.00", "1", "PepsiCan.png")
  88.         table.Rows.Add(108, "Coke Large", "55.00", "1", "CocaColaCan.png")
  89.         table.Rows.Add(109, "7Up Large", "60.00", "1", "7UpCan.png")
  90.         Return table
  91.     End Function

  92. End Class
คัดลอกไปที่คลิปบอร์ด


ดาวน์โหลดโค้ดต้นฉบับเต็ม VB.NET (2010) ได้ที่นี่ ...



ขออภัย! โพสต์นี้มีไฟล์แนบหรือรูปภาพที่ไม่ได้รับอนุญาตให้คุณเข้าถึง

คุณจำเป็นต้อง ลงชื่อเข้าใช้ เพื่อดาวน์โหลดหรือดูไฟล์แนบนี้ คุณยังไม่มีบัญชีใช่ไหม? ลงทะเบียน

x
สิ่งที่ดีกว่าการให้ คือการให้แบบไม่มีที่สิ้นสุด

0

กระทู้

1

โพสต์

46

เครดิต

Newbie

Rank: 1

เครดิต
46
โพสต์ 2019-3-21 20:52:12 | ดูโพสต์ทั้งหมด

ขอบคุณครับ
ขออภัย! คุณไม่ได้รับสิทธิ์ในการดำเนินการในส่วนนี้ กรุณาเลือกอย่างใดอย่างหนึ่ง ลงชื่อเข้าใช้ | ลงทะเบียน

รายละเอียดเครดิต

ข้อความล้วน|อุปกรณ์พกพา|ประวัติการแบน|G2GNet.com  

GMT+7, 2024-5-5 21:22 , Processed in 0.166597 second(s), 4 queries , File On.

Powered by Discuz! X3.4, Rev.62

Copyright © 2001-2020 Tencent Cloud.

ตอบกระทู้ ขึ้นไปด้านบน ไปที่หน้ารายการกระทู้