Tampilan
awal.
Coding
untuk frmPegawai.cs
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.IO;
using
System.Windows.Forms;
namespace
WindowsFormsApplication1
{
public partial class frmPegawai : Form
{
public
frmPegawai()
{
InitializeComponent();
}
private
void frmPegawai_Load(object
sender, EventArgs e)
{
dgPegawai.AlternatingRowsDefaultCellStyle.BackColor = Color.Aquamarine;
}
private
void cmdSimpan_Click(object
sender, EventArgs e)
{
string[]
row = { txtNIK.Text, txtNAMA.Text, txtALAMAT.Text };
dgPegawai.Rows.Add(row);
dgPegawai.AutoResizeColumns();
}
private
void dgPegawai_CellEnter(object sender, EventArgs
e)
{
txtNIK.Text =
dgPegawai.CurrentRow.Cells[0].Value.ToString();
txtNAMA.Text =
dgPegawai.CurrentRow.Cells[1].Value.ToString();
txtALAMAT.Text =
dgPegawai.CurrentRow.Cells[2].Value.ToString();
}
private
void cmdHapus_Click(object
sender, EventArgs e)
{
dgPegawai.Rows.RemoveAt(dgPegawai.SelectedRows[0].Index);
}
private
void cmdUbah_Click(object
sender, EventArgs e)
{
foreach
(DataGridViewRow row in dgPegawai.Rows)
{
DataGridViewCell
cell = row.Cells[0];
cell.Value = txtNIK.Text;
}
}
}
}
Ubah
Button:
Hapus Button:
0 komentar:
Post a Comment
Note: only a member of this blog may post a comment.