Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > [VB.net] รายละเอียดของ control มันเกินหน้าจอ อยากทำเป็น scrolbar เลื่อนไปมา ทำอย่างไรครับ



 

[VB.net] รายละเอียดของ control มันเกินหน้าจอ อยากทำเป็น scrolbar เลื่อนไปมา ทำอย่างไรครับ

 



Topic : 058007



โพสกระทู้ ( 227 )
บทความ ( 0 )



สถานะออฟไลน์




เป็นงานที่ต้องสร้างปุ่มไว้เยอะๆ ประมาณ 120 เเถวเเต่ว่าหน้าจอเต็มที่มันรับได้ประมาณ 40 เเถวครับ เลยอยากทำเป็น scrolbar เลื่อนไปมาได้ ครับ


code รันได้เลยนะครับ ผมสร้างเป็นเเบบรันไทม์ ไม่ต้องเพิ่มคอนโทรลอะไร

Code (VB.NET)
Imports System.Collections.Generic
Imports System.Windows.Forms

Public Class Form1
    Private ButtonList As List(Of Button) = New List(Of Button)()
    Private Const MaxButtonNumber As Integer = 24 * 120
    'Private Const MaxButtonNumber As Integer = 8 * 8
    Private AttachEventButton As Button = New Button()
    Private DetachEventButton As Button = New Button()
    Private Calculate As Button = New Button()
    Private BlackColorButton As Button = New Button()
    Private WhiteColorButton As Button = New Button()
    Private WhiteAll As Button = New Button()
    Private BlackAll As Button = New Button()
    Private ChangeColor As Button = New Button()
    Private PaintMode As ComboBox = New ComboBox()


    Dim ArrayLED(MaxButtonNumber) As Integer
    Dim j As Integer
    Dim NumberButton As Integer
    Dim BtLeft As Integer = 20
    Dim bufferMCS51 As String
    Dim PenColor As String = "White"
    Dim testt As Integer = 1
    Dim Mode As String = "Point Mode"




    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Width = 1300
        Me.Height = 750

        OnCreateButton()
        OnCreateCombobox()

    End Sub

    Private Sub AllButton_Move(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim MoveButton As Button = sender
        'MessageBox.Show("กดปุ่ม [" + ClickButton.Name + "] แล้ว ", "ตรวจสอบการกดปุ่ม")

        '//////////// convert name bt to array ///////////////////////////////////
        NumberButton = CInt(MoveButton.Name)
        If (Mode = "Line Mode") Then
            If (PenColor = "White") Then
                MoveButton.BackColor = Color.White
                'MoveButton.Image = WindowsApplication1.My.Resources.white
                ArrayLED(NumberButton) = 0
            Else
                MoveButton.BackColor = Color.Black
                'MoveButton.Image = WindowsApplication1.My.Resources.black
                ArrayLED(NumberButton) = 1
            End If
        End If

    End Sub
    Private Sub AllButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim ClickButton As Button = sender
        Dim i As Integer = 0
        'MessageBox.Show("กดปุ่ม [" + ClickButton.Name + "] แล้ว ", "ตรวจสอบการกดปุ่ม")

        '//////////// convert name bt to array ///////////////////////////////////
        NumberButton = CInt(ClickButton.Name)
        If (Mode = "Point Mode") Then
            If (ArrayLED(CInt(ClickButton.Name)) = 1 = 0) Then
                ClickButton.BackColor = Color.Black
                'ClickButton.Image = WindowsApplication1.My.Resources.black
                ArrayLED(NumberButton) = 1
            Else
                ClickButton.BackColor = Color.White
                'ClickButton.Image = WindowsApplication1.My.Resources.white
                ArrayLED(NumberButton) = 0
            End If
        End If

    End Sub
    Private Sub AttachEventButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        For Each itemButton As Button In ButtonList
            AddHandler itemButton.MouseEnter, AddressOf AllButton_Move
            AddHandler itemButton.Click, AddressOf AllButton_Click

        Next
        MessageBox.Show(Me, "เชื่อมต่อปุ่มแล้ว ", "Event attach")
        AttachEventButton.Visible = False
        DetachEventButton.Visible = True
        Calculate.Enabled = True
        BlackColorButton.Enabled = True
        WhiteColorButton.Enabled = True
        BlackAll.Enabled = True
        WhiteAll.Enabled = True
        ChangeColor.Enabled = True
    End Sub

    Private Sub detachEventButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        For Each itemButton As Button In ButtonList
            RemoveHandler itemButton.MouseEnter, AddressOf AllButton_Move
            RemoveHandler itemButton.Click, AddressOf AllButton_Click
        Next
        MessageBox.Show(Me, "ยกเลิกการเชื่อมต่อปุ่ม", "Event detach" _
            , MessageBoxButtons.OK, MessageBoxIcon.Information)
        AttachEventButton.Visible = True
        DetachEventButton.Visible = False
        Calculate.Enabled = False
        BlackColorButton.Enabled = False
        WhiteColorButton.Enabled = False
        BlackAll.Enabled = False
        WhiteAll.Enabled = False
        ChangeColor.Enabled = False
    End Sub
    Private Sub Calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        '//////////// Constance sennt to MCS-51 = SentMCS51(j) ////////////
        Dim SentMCS51(MaxButtonNumber / 8) As String
        Dim test As String = ""
        Dim j As Integer = 0
        For i = 0 To MaxButtonNumber - 1
            bufferMCS51 = bufferMCS51 + ArrayLED(i).ToString
            '/////////////////////// cal hex ///////////////////////////////
            'MsgBox("ปุ่มที่ " + i.ToString + "มีค่าเท่ากับ" + ArrayLED(i).ToString)
            If i Mod 8 = 7 Then
                CalculateHeximal()
                SentMCS51(j) = bufferMCS51
                test = (test & SentMCS51(j) & vbCrLf)
                'MsgBox(bufferMCS51.ToString + (j + 1).ToString)
                bufferMCS51 = ""
                j = j + 1

            End If

        Next
        MsgBox(test)
    End Sub
    Private Sub OnCreateButton()
        For i As Integer = 0 To MaxButtonNumber - 1
            Dim ActiveButton As Button = New Button()
            With ActiveButton
                If (testt = 1) Then
                    .BackColor = Color.White
                Else
                    .BackColor = Color.Black
                End If
                .FlatStyle = FlatStyle.Flat
                ArrayLED(i) = 0
                '//////////////////// SIZE //////////////////////////
                .Height = 27
                .Width = 27
                '/////////////////// X,Y ////////////////////////////
                If (i Mod 24 > 0) Then
                    .Left = BtLeft
                Else
                    BtLeft = BtLeft + 27
                    .Left = BtLeft
                End If
                '////////////////////////////////////////////////////

                .Top = 30 + ((i Mod 24) * (ActiveButton.Height + 0))

                '///////////////// NAME /////////////////////////////
                .Name = i.ToString()
                .BackColor = Color.White
                ' .Image = WindowsApplication1.My.Resources.white
                .BackColor = Color.White
            End With
            Me.Controls.Add(ActiveButton)
            ButtonList.Add(ActiveButton)
        Next

        '////////////////////////////////////////////////////////////
        With AttachEventButton
            .Text = "Connect Button"
            .Height = 30
            .Width = 120
            .Left = ButtonList(MaxButtonNumber - 1).Left + 30
            .Top = ButtonList(0).Top
            .Visible = True
        End With
        Me.Controls.Add(AttachEventButton)
        '////////////////////////////////////////////////////////////
        With DetachEventButton
            .Text = "Disconnect Button"
            .Height = 30
            .Width = 120
            .Left = AttachEventButton.Left
            .Top = AttachEventButton.Top
            .Visible = False
        End With
        Me.Controls.Add(DetachEventButton)
        '////////////////////////////////////////////////////////////
        With Calculate
            .Text = "Cal LED"
            .Height = 30
            .Width = 120
            .Left = AttachEventButton.Left
            .Top = AttachEventButton.Top + 40
            .Visible = True
            .Enabled = False
        End With
        Me.Controls.Add(Calculate)
        '///////////////////////// Add event ///////////////////////////
        '////////////////////////////////////////////////////////////
        With BlackColorButton

            .Height = 60
            .Width = 60
            .Left = Calculate.Left
            .Top = Calculate.Top + 40
            .Visible = True
            .BackColor = Color.Black
            '.Image = WindowsApplication1.My.Resources.fanta_emo107
            .Enabled = False
        End With
        Me.Controls.Add(BlackColorButton)
        '////////////////////////////////////////////////////////////
        With WhiteColorButton

            .Height = 60
            .Width = 60
            .Left = Calculate.Left
            .Top = Calculate.Top + 40
            .Visible = False
            .BackColor = Color.White
            ' .Image = WindowsApplication1.My.Resources.eraser1
            .Enabled = False
        End With
        Me.Controls.Add(WhiteColorButton)
        '////////////////////////////////////////////////////////////
        With WhiteAll

            .Height = 20
            .Width = 50
            .Left = WhiteColorButton.Right + 10
            .Top = Calculate.Top + 40
            .Visible = True
            .BackColor = Color.White
            .Enabled = False
        End With
        Me.Controls.Add(WhiteAll)
        '////////////////////////////////////////////////////////////
        With BlackAll

            .Height = 20
            .Width = 50
            .Left = WhiteColorButton.Right + 10
            .Top = WhiteAll.Bottom + 2
            .Visible = True
            .BackColor = Color.Black
            .Enabled = False
        End With
        Me.Controls.Add(BlackAll)
        '////////////////////////////////////////////////////////////
        With ChangeColor

            .Height = 20
            .Width = 50
            .Left = WhiteColorButton.Right + 10
            .Top = BlackAll.Bottom + 2
            .Visible = True
            '.Image = WindowsApplication1.My.Resources.wbbw
            .Enabled = False
        End With
        Me.Controls.Add(ChangeColor)
        '///////////////////////// Add event ///////////////////////////
        AddHandler AttachEventButton.Click, AddressOf Me.AttachEventButton_Click
        AddHandler DetachEventButton.Click, AddressOf Me.detachEventButton_Click
        AddHandler Calculate.Click, AddressOf Me.Calculate_Click
        AddHandler WhiteColorButton.Click, AddressOf Me.WhiteColorButton_Click
        AddHandler BlackColorButton.Click, AddressOf Me.BlackColorButton_Click
        AddHandler BlackAll.Click, AddressOf Me.BlackAll_Click
        AddHandler WhiteAll.Click, AddressOf Me.WhiteAll_Click
        AddHandler ChangeColor.Click, AddressOf Me.ChangeColor_Click

    End Sub
    Public Sub CalculateHeximal()
        '///////////// Binary to Decimal  to Heximal /////////////////////
        Dim NumberDecimal As Integer
        Dim NumberBinary As String = bufferMCS51
        Dim BitWeight As Integer = 0
        Dim NumberHeximal As String = ""
        Dim SubHeximal1 As String = ""
        Dim SubHeximal2 As String = ""
        '///////////////SUB bufferMCS51 //////////////////////////////////
        SubHeximal1 = NumberBinary.Substring(0, 4)
        SubHeximal2 = NumberBinary.Substring(4)
        '///////////////////////// Case 1 ////////////////////////////////
        For i = 4 To 1 Step -1
            If Mid$(SubHeximal1, i, 1) <> 0 Then
                NumberDecimal = NumberDecimal + ((2 ^ BitWeight) * Mid$(SubHeximal1, i, 1))
                ' เพิ่มค่าเลขยกกำลังขึ้นอีก 1
            End If
            BitWeight = BitWeight + 1
        Next
        SubHeximal1 = Hex(NumberDecimal).ToString
        '/////////////////// Clear Buffer ////////////////////////////////
        NumberDecimal = 0
        BitWeight = 0
        '/////////////////////////Case 2 /////////////////////////////////
        For i = 4 To 1 Step -1
            If Mid$(SubHeximal2, i, 1) <> 0 Then
                NumberDecimal = NumberDecimal + ((2 ^ BitWeight) * Mid$(SubHeximal2, i, 1))
                ' เพิ่มค่าเลขยกกำลังขึ้นอีก 1
            End If
            BitWeight = BitWeight + 1
        Next
        SubHeximal2 = Hex(NumberDecimal).ToString
        NumberHeximal = SubHeximal1 + SubHeximal2
        bufferMCS51 = NumberHeximal
        '/////////////////////////////////////////////////////////////////
    End Sub
    Private Sub BlackColorButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        PenColor = "Black"
        BlackColorButton.Visible = False
        WhiteColorButton.Visible = True
    End Sub
    Private Sub WhiteColorButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        PenColor = "White"
        BlackColorButton.Visible = True
        WhiteColorButton.Visible = False
    End Sub
    Private Sub WhiteAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        For Each itemButton As Button In ButtonList
            itemButton.BackColor = Color.White
            ' itemButton.Image = WindowsApplication1.My.Resources.white
            ArrayLED(CInt(itemButton.Name)) = 0
        Next
    End Sub
    Private Sub BlackAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        For Each itemButton As Button In ButtonList
            itemButton.BackColor = Color.Black
            'itemButton.Image = WindowsApplication1.My.Resources.black
            ArrayLED(CInt(itemButton.Name)) = 1
        Next
    End Sub
    Private Sub ChangeColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        For Each itemButton As Button In ButtonList
            If (ArrayLED(CInt(itemButton.Name)) = 1) Then
                itemButton.BackColor = Color.White
                'itemButton.Image = WindowsApplication1.My.Resources.white
                ArrayLED(CInt(itemButton.Name)) = 0
            Else
                itemButton.BackColor = Color.Black
                'itemButton.Image = WindowsApplication1.My.Resources.black
                ArrayLED(CInt(itemButton.Name)) = 1
            End If

        Next
    End Sub
    Public Sub OnCreateCombobox()
        With PaintMode
            .Left = BlackColorButton.Left
            .Top = BlackAll.Bottom + 30
            .Text = ("---Select Mode---")
            .Items.Add("Point Mode")
            .Items.Add("Line Mode")
            '.Enabled = False
        End With
        Me.Controls.Add(PaintMode)
        AddHandler PaintMode.SelectedIndexChanged, AddressOf Me.PaintMode_SelectIndexChange

    End Sub
    Private Sub PaintMode_SelectIndexChange(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If (PaintMode.Text = "Line Mode") Then
            Mode = "Line Mode"
        ElseIf (PaintMode.Text = "Point Mode") Then
            Mode = "Point Mode"
        End If
    End Sub
End Class





Tag : .NET









ประวัติการแก้ไข
2011-03-29 15:52:50
2011-03-29 15:54:29
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-03-29 15:47:01 By : Cyg View : 1103 Reply : 1
 

 

No. 1



โพสกระทู้ ( 227 )
บทความ ( 0 )



สถานะออฟไลน์


ได้คำตอบละครับ

set property ของ form ที่ชื่อ Autoscollbar ค่ะ set ให้ค่าเป็น True ปลาตายน้ำตื้นเเท้ๆผม






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-03-29 16:01:38 By : Cyg
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : [VB.net] รายละเอียดของ control มันเกินหน้าจอ อยากทำเป็น scrolbar เลื่อนไปมา ทำอย่างไรครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่