Nanda's Blog

Share a smile, Share information

Get Header Name In datagridview(Visual Basic 2008) October 26, 2010

Aku posting sesuatu tentang Visual Basic dah nie, mungkin ada diantara kalian yang lagi nyari gimana caranya buat dapetin nama header datagridview saat kalian select cell yang ada di dalam datagridview :

Keterangan :

Datagridview = datagridview_double_akhir

textbox1(textbox untuk header name datagridview) = TextBox_field

textbox2(textbox untuk isi cell datagridview) = TextBox_id_double

‘ saat cellnya diklik maka textbox1 akan terisi dengan header name cell yang diklik

Private Sub datagridview_double_akhir_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles datagridview_double_akhir.CellClick
Dim x, y As Integer
x = datagridview_double_akhir.CurrentCell.ColumnIndex
y = datagridview_double_akhir.CurrentCell.RowIndex
TextBox_field.Text = datagridview_double_akhir.Columns(x).Name

TextBox_id_double.Text = datagridview_double_akhir.Item(x, y).Value

End Sub

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s