Radiobutton pada GroupBox dengan kode

pada Visual Basic 2010 buat 1 form, misalnya: frmTest, terus isikan kode berikut:

'Coded by shabirin | shabirin@yahoo.co.id

Public Class frmTest

    Dim radioPoint As New Point(7, 12)
    Dim location = New Point(10, 10)
    Dim newGroupBox As New GroupBox

    Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
        With newGroupBox
            .Text = "Test"
            .Width = 100
            .Controls.Add(AddRadioToGroupBox("Ayam"))
            .Controls.Add(AddRadioToGroupBox("Ikan"))
            .Controls.Add(AddRadioToGroupBox("Telor"))
            .Height = radioPoint.Y + 5
            .Location = location
        End With
        Me.Controls.Add(newGroupBox)
    End Sub

    Public Function AddRadioToGroupBox(ByVal Text As String) As RadioButton
        Dim newRadio = New RadioButton
        newRadio.Text = Text
        newRadio.Width = 90
        newRadio.Location = radioPoint
        radioPoint.Y += newRadio.Height
        Return newRadio
    End Function 

End Class
  1. Belum ada trackback.

Tinggalkan Balasan

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Ubah )

Twitter picture

You are commenting using your Twitter account. Log Out / Ubah )

Facebook photo

You are commenting using your Facebook account. Log Out / Ubah )

Connecting to %s

Ikuti

Get every new post delivered to your Inbox.