Berbagi Cerita, Catatan, Pengalaman ngoding dan Secangkir Teh Hangat.

Friday, January 6, 2017

Membuat Sendiri Inputbox sederhana di VB.Net

Membuat sendiri custom Inputbox sederhana 

Inputbox bawaan VB.Net terkadang tidak cocok dengan kebutuhan kita, ada kalanya kita membutuhkan format inputbox yang custom, nah post ini akan memberikan contoh bagaimana membuat Inputbox yang sangat sederhana.

Desain Form

Kita akan mendesain form inputbox yang sederhana terdisi dari, 1 Label, 1 Textbox, 1 Picturebox, 1 Toolbar, 2 Button.
Disample kali ini tidak menggunakan button control biasa tapi menggunakan Toolstrip Button

1 Label : lblpesan
1 Textbox : tpesan
1 Picturebox : ikon
1 ToolstripButton : btn_ok
1 ToolstripButton : btn_cancel






Script Form Inputbox

    Public Class view_inputbox_form
    Public Property JudulForm As String
    Public Property Pesan As String
    Public Property UserInput As String
    Public Sub New()
        InitializeComponent()
    End Sub
    Public Sub New(ByVal title As String, ByVal promp As String)
        InitializeComponent()
        Me.JudulForm = title
        Me.Pesan = promp
    End Sub
    Private Sub view_inputbox_form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = JudulForm
        lblpesan.Text = Pesan
    End Sub
    Private Sub btn_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ok.Click
        Me.UserInput = tpesan.Text
        DialogResult = vbOK
    End Sub
    Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
        DialogResult = vbCancel
    End Sub
    Private Sub tpesan_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tpesan.KeyDown
        If e.KeyCode = 13 Then
            Me.UserInput = tpesan.Text
            DialogResult = vbOK
        End If
    End Sub
End Class




Script untuk memanggil Form Inputbox dari Form lain.


        Dim input_form As New view_inputbox_form("Konfirmasi", "Berikan Keterangan, Mengapa anda mengotorisasi surat jalan ini")
        input_form.ShowDialog()
        If input_form.DialogResult = Windows.Forms.DialogResult.Cancel Then
            MsgBox("Anda membatalkan proses approve", MsgBoxStyle.Exclamation)
        Else
            Approve(input_form.UserInput)
        End If




Selamat Mencoba.

Bahasa : VB.Net
IDE : Visual Studio 2010
Framework : .Net 3.5

sekian dulu berbaginya, jangan lupa like, komen, share.
jangan lupa sertakan link blog ini sebagai sumber kalo kalian mau paste tutorial ini di blog kalian.
Share:

1 comment:

  1. JT Slots Casino - Jacksonville, Mississippi - KT Hub
    JTG Slots Casino 대전광역 출장샵 provides 영천 출장마사지 a 평택 출장샵 wide variety of slots for players in Mississippi. Casino 사천 출장안마 offers you 제천 출장안마 a wide variety of games to choose from,

    ReplyDelete

Powered by Blogger.

Ads 468x60px

Freelancer

Jaka Pradesa

Data Entry and Softwares

E: j.r.pradesa@gmail.com

Hire me on Freelancer.com

Social Icons