 |
|
vb 2013 build tabpage เสร็จแล้วจะวนลูปเอารูปไปใส่ไว้ด้านในแต่ละ page อย่างไรครับ |
|
 |
|
|
 |
 |
|
เพิ่ม new picture box ในแต่ละ tabpage หลักการทำเหมือนที่เพิ่ม tabpage ครับ
|
 |
 |
 |
 |
Date :
2015-04-22 08:30:02 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เป็นการดึกจาก database มาครับ แล้วมี demo ให้ดูนิหน่อยไหมครับ
|
 |
 |
 |
 |
Date :
2015-04-22 08:41:15 |
By :
Mr. Kay |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอดูโค๊ดที่ใช้เพิ่ม tabpage หน่อยครับ
|
 |
 |
 |
 |
Date :
2015-04-22 08:44:20 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
'build myTabGroup
Private Sub BuildTabGroup(ByVal IdCategory As String, ByVal strTextOne As String, ByVal strTextTwo As String, ByVal strTextThree As String)
'build tabcontrol
Me.flowlayoutpanelContent.Controls.Clear()
myTabControl = New TabControl()
myTabControl.ItemSize = New Size(300, 40)
myTabControl.Size = New Size(534, 729)
flowlayoutpanelContent.Controls.Add(myTabControl)
'build tabpage
'mytabone
If strTextOne.ToString <> "" Then
myTabPage = New TabPage()
myTabPage.Text = strTextOne
myTabControl.TabPages.Add(myTabPage)
End If
'mytabtwo
If strTextTwo.ToString <> "" Then
myTabPage = New TabPage()
myTabPage.Text = strTextTwo
myTabControl.TabPages.Add(myTabPage)
End If
'mytabthree
If strTextThree.ToString <> "" Then
myTabPage = New TabPage()
myTabPage.Text = strTextThree
myTabControl.TabPages.Add(myTabPage)
End If
End Sub
|
 |
 |
 |
 |
Date :
2015-04-22 08:47:25 |
By :
txais |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นี่คือ code ตอน query จาก database ครับ
Code (VB.NET)
'sub even show button product product
Private Sub ClickHandlerPageProduct(ByVal getGroupId As String)
'Button To add TextBoxes
Dim sqlProduct As String
Dim productButton As Button
Dim i As Integer
Try
'query product build control button from id group
sb = New StringBuilder
sb.Append("SELECT id,code,name_thai,name_eng,sell_price,images FROM product")
sb.Append(" WHERE group_id=@group_id") ' AND glass=@glass
sb.Append(" ORDER BY code ASC")
sqlProduct = sb.ToString
cmd = New SqlCommand
With cmd
.Parameters.Clear()
.Parameters.Add("@group_id", SqlDbType.Int).Value = getGroupId.ToString
' .Parameters.Add("@glass", SqlDbType.SmallInt).Value = getGlass.ToString
.Connection = conn
.CommandText = sqlProduct
dr = .ExecuteReader
If dr.HasRows Then
dt = New DataTable
dt.Load(dr)
'myTabControl.TabPages(0).Controls.Clear()
For i = 0 To dt.Rows.Count - 1
productButton = New Button
productButton.ForeColor = Color.Red
productButton.TextAlign = ContentAlignment.BottomCenter
productButton.BackgroundImageLayout = ImageLayout.Stretch
productButton.Cursor = Cursors.Hand
productButton.Width = 100
productButton.Height = 100
'set id product
productButton.TabIndex = dt.Rows(i).Item("id").ToString
productButton.Name = dt.Rows(i).Item("code").ToString
productButton.Text = dt.Rows(i).Item("name_thai").ToString
productButton.AccessibleName = dt.Rows(i).Item("name_eng").ToString
productButton.Tag = dt.Rows(i).Item("sell_price").ToString
'check image null default
'If IsDBNull(dt.Rows(i).Item("images")) Then
' productButton.BackgroundImage = defaultImage
'Else
' productButton.BackgroundImage = BytesToImages(dt.Rows(i).Item("images"))
'End If
'myTabControl.TabPages(0).Controls.Add(productButton)
AddHandler productButton.Click, AddressOf ClickAddToGridView
Next
End If
End With
dr.Close()
Catch ex As Exception
Console.WriteLine("ERROR Sub ClickHandlerPageProduct")
Exit Sub
End Try
End Sub
|
 |
 |
 |
 |
Date :
2015-04-22 08:49:46 |
By :
Mr. Kay |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

Code (VB.NET)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
AddTab(Image.FromFile("D:\SWDownload\Wallpaper\01024418.jpg"), "ไอ้ก้อนหินเฮ็งซวย") 'การใช้งาน
End Sub
'ส่วนของการเพิ่ม TabPage
Private Sub AddTab(pathPic As String, Optional strTabString As String = "")
Dim tab As TabPage = New TabPage(strTabString)
Dim pic As PictureBox = New PictureBox
pic.Image = pathPic
pic.Dock = System.Windows.Forms.DockStyle.Fill 'ทำให้เต็มจอ
tab.Controls.Add(pic) 'เพิ่ม picture box ใน TabPage
Me.TabControl1.Controls.Add(tab) 'เพิ่ม TabPage ใน TabControl
End Sub
หลักการ add control แบบบ้านๆคือให้ดู ใน Private Sub InitializeComponent() คือ add control ไปก่อนแล้วไปดูใน Private Sub InitializeComponent() ว่ามัน add control ยังไงได้ผล 1000000000000000000000000000000 %
|
 |
 |
 |
 |
Date :
2015-04-22 09:22:32 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

คือตอนนี้หน้าจอผม มีลักษณะคล้ายๆๆแบบนี้ครับ แล้วพอผมเลือก category ด้านข้างก็ให้มัน create tab มาโดยมี 3 tab คือ เย็น,ร้อน,ปั่น และถ้าอันไหนไม่ได้อยู่ในเงือนไขนี้ก็จะมี tab แค่อันเดียว แล้วใน tab จะมีรูปภาพเฉพาะ เย็น ก็เป็นรูปชนิด เย็น อย่างเดียว ร้อนก็เป็นชนิดร้อนอย่างเดียว โดยผมเก็บ datatype image mssql ครับ ช่วยด้วยครับ
|
 |
 |
 |
 |
Date :
2015-04-22 11:01:41 |
By :
Mr. Kay |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|