jujurssAvatar border
TS
jujurss
Help program C# enable/disable button
gan, ane mau nanya gan gimana cara nya disable button Pesan saat checkbox menu belum di ceklis caranya gimana ya gan

MainForm.cs
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace pertemuan10
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}

private void checkBoxMenu1_CheckStateChanged(object sender, EventArgs e)
{
if (checkBoxMenu1.Checked == true)
{
textBox1Menu1.Visible = true;
textBox1Menu1.Focus();
}
else
{
textBox1Menu1.Text = "";
textBox1Menu1.Visible = false;
}
}

private void checkBoxmenu2_CheckStateChanged(object sender, EventArgs e)
{
if (checkBoxmenu2.Checked == true)
{
textBoxMenu2.Visible = true;
textBoxMenu2.Focus();
}
else
{
textBoxMenu2.Text = "";
textBoxMenu2.Visible = false;


}

}

private void checkBoxmenu3_CheckStateChanged(object sender, EventArgs e)
{
if (checkBoxmenu3.Checked == true)
{
textBoxMenu3.Visible = true;
textBoxMenu3.Focus();
}
else
{
textBoxMenu3.Text = "";
textBoxMenu3.Visible = false;


}


}

private void buttonpesan_Click(object sender, EventArgs e)
{
int subtotal = 0, diskon = 0;

if (checkBoxMenu1.Checked)
{
subtotal += 5000 * int.Parse(textBox1Menu1.Text);
}
if (checkBoxmenu2.Checked)
{
subtotal += 8000 * int.Parse(textBoxMenu2.Text);
}
if (checkBoxmenu3.Checked)
{
subtotal += 10000 * int.Parse(textBoxMenu3.Text);
}
textBoxSubtotal.Text = Convert.ToString(subtotal);

if (radioButtonya.Checked)
{
diskon = Convert.ToInt32(0.1 * subtotal);
}
textBoxSubtotal.Text = Convert.ToString(subtotal);
textBoxDiskon.Text = Convert.ToString(diskon);

int total = subtotal - diskon;
textBoxTbayar.Text = Convert.ToString(total);
}

private void textBox1Menu1_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if (!Char.IsDigit(ch) && ch != 8)
{
e.Handled = true;
}
}

private void textBoxMenu2_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if (!Char.IsDigit(ch) && ch != 8)
{
e.Handled = true;
}
}

private void textBoxMenu3_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if (!Char.IsDigit(ch) && ch != 8)
{
e.Handled = true;
}
}

private void textBox1Menu1_Validating(object sender, CancelEventArgs e)
{
if (textBox1Menu1.Text == "")
{
MessageBox.Show("Anda Belum Mengisi Textbox1");
}
}

private void textBoxMenu2_Validating(object sender, CancelEventArgs e)
{
if (textBoxMenu2.Text == "")
{
MessageBox.Show("Anda Belum Mengisi Textbox2");
}
}

private void textBoxMenu3_Validating(object sender, CancelEventArgs e)
{
if (textBoxMenu3.Text == "")
{
MessageBox.Show("Anda Belum Mengisi Textbox3");
}
}
}
}





jadi saya ingin kalau Menu nya itu di ceklis dulu gan baru Button Pesan nya bisa di klik gimana ya gan?emoticon-Bingung (S)emoticon-Bingung (S)
0
2K
8
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Urutan
Terbaru
Terlama
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Komunitas Pilihan