Class Form1
|
||
Variabel Komponen
|
Event
|
Source Code
|
Form1
|
Load
|
private void Form1_Load(object
sender, EventArgs e)
{
DataColumn Nama = new DataColumn("Nama",
Type.GetType("System.String"));
DataColumn Waktu = new
DataColumn("Waktu", Type.GetType("System.Decimal"));
DataColumn Harga = new
DataColumn("Harga", Type.GetType("System.Decimal"));
DataColumn Total_Harga = new
DataColumn("Total Harga",
Type.GetType("System.Decimal"));
Total_Harga.Expression = "Harga *
Waktu";
dt.Columns.Add(Nama);
dt.Columns.Add(Waktu);
dt.Columns.Add(Harga);
dt.Columns.Add(Total_Harga);
}
|
btnInputData
|
Click
|
private void btnInputData_Click(object sender, EventArgs e)
{ dt.Rows.Add(txtNama.Text, txtWaktu.Text, txtHarga.Text);
dgv.DataSource = dt;
}
|
btnDeleteSelectedData
|
Click
|
private void
btnDeleteSelectedData_Click(object sender, EventArgs e)
{
{
foreach (DataGridViewCell oneCell in
dgv.SelectedCells)
{
if (oneCell.Selected)
dgv.Rows.RemoveAt(oneCell.RowIndex);
}
}
}
|
btnFilterWaktu
|
Click
|
private void btnFilterWaktu_Click(object
sender, EventArgs e)
{
DataTable NewDT = new
DataTable();
NewDT = dt.Copy();
NewDT.DefaultView.RowFilter =
"Waktu = ' " + txtFilterWaktu.Text + " ' ";
dgv.DataSource = NewDT;
}
|
btnFilterHarga
|
Click
|
private void btnFilterHarga_Click(object
sender, EventArgs e)
{
DataTable NewDT = new
DataTable();
NewDT = dt.Copy();
NewDT.DefaultView.RowFilter =
"Harga = ' " + txtFilterHarga.Text + " ' ";
dgv.DataSource = NewDT;
}
|
btnResetFilter
|
Click
|
private void btnResetFilter_Click(object
sender, EventArgs e)
{
DataTable NewDT = new
DataTable();
NewDT = dt.Copy();
dgv.DataSource = NewDT;
}
|
Langganan:
Posting Komentar (Atom)
mantap,gann
BalasHapus