You are on page 1of 10

Pemrograman Visual (TH22012 )

by Kartika Firdausy
pvisual@ee.uad.ac.id
blog.uad.ac.id/kartikaf
kartikaf.wordpress.com

DataGridView

DataGridView
A data grid view is a rectangular control
made of columns and rows:

DataGridView
The top section of the control displays column headers as gray boxes
with each showing a caption.
On the left side, there are gray boxes referred to as row headers.
The cells are the intersections of the columns and the rows.
Those cells are white.
These are the default characteristics of columns, rows, and cells.
In reality, most aspects can be customized. They can show different
colors, different widths, and different heights.

Toolbox DataGridView

Menambah kolom Add Column

Add Column
Nama kolom

Header kolom

Tipe kolom

Hasil

Memberi judul kolom


dataGridViewTabel->Columns->Add("USD", "USD");
dataGridViewTabel->Columns->Add("Rupiah", "Rupiah");

Event handler buttonHitung (Click)


int Kurs, Rupiah, USD;
Kurs = Convert::ToInt16(textBoxKurs->Text);
dataGridViewTabel->Rows->Clear();
int n = dataGridViewTabel->Rows->Add(9);
for (int i=1; i<=10; i++)
{
USD = i;
Rupiah = i*Kurs;
dataGridViewTabel->Rows[i-1]->Cells["USD"]->
Value = Convert::ToString(USD);
dataGridViewTabel->Rows[i-1]->Cells["Rupiah"]->
Value = Convert::ToString(Rupiah);
}

You might also like