How to visit the invisible column

  • Thread starter Thread starter ssailor
  • Start date Start date
S

ssailor

I have a datagridview filled with data from an external table.
I store the Key field in the first column and make it invisible.
But I want to visit this invisible column to get the Key data when
I double-click a selected row. How can i do? Thanks in advance.
 
Try code like:

Dim key as Object = dataGridView1("HiddenColName",
e.RowIndex).Value

This assumes you hide the column using

dataGridView1.Columns("HiddenColName").Visible = False

=====================
Clay Burch
Syncfusion, Inc.
 
ssailor,

When you click on a cell, it should raise a CellClick event.
http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.cellclick.aspx

From this event handler, you can get to the row, and then pull the cells by
index.

Private Sub dataGridView1_CellClick(ByVal sender As Object, _
ByVal e As DataGridViewCellEventArgs) _
Handles dataGridView1.CellClick

If turn.Text.Equals(gameOverString) Then Return

Dim cell As DataGridViewImageCell = _
CType(dataGridView1.Rows(e.RowIndex). _
Cells(e.ColumnIndex), DataGridViewImageCell)
If (cell.Value Is blank) Then
If IsOsTurn() Then
cell.Value = o
Else
cell.Value = x
End If
ToggleTurn()
ToolTip(e)
End If
If IsAWin() Then
turn.Text = gameOverString
End If
End Sub

Hope this helps,


Steve
 
Back
Top