Skip to content

Instantly share code, notes, and snippets.

@NPS-ARCN-CAKN
Created December 4, 2017 21:50
Show Gist options
  • Save NPS-ARCN-CAKN/1828fe10f91516730d12f9d02f031882 to your computer and use it in GitHub Desktop.
Save NPS-ARCN-CAKN/1828fe10f91516730d12f9d02f031882 to your computer and use it in GitHub Desktop.
Get the value of a GridEX cell (Visual Basic .NET)
'the gridex contains a column called FilesDirectory where the project's files are stored
'this sub will get the currently selected row in the GridEX, identify the FilesDirectory value
'and attempt to open the path using a process (file explorer, most likely)
Try
'get the current row of the VS GridEX
If Not Me.TblVitalSignsGridEX.CurrentRow Is Nothing Then
Dim CurrentRow As GridEXRow = Me.TblVitalSignsGridEX.CurrentRow
'loop through the columns and look for the FilesDirectory columns
For i As Integer = 0 To CurrentRow.Cells.Count - 1
If CurrentRow.Cells(i).Column.Key = "FilesDirectory" Then
'if there is a value
If Not IsDBNull(CurrentRow.Cells(i).Value) Then
Dim Directory As String = ""
Directory = CurrentRow.Cells(i).Value
'if the FilesDirectory value is a valid directory
If My.Computer.FileSystem.DirectoryExists(Directory) Then
'try to start it using the default program (probably file explorer)
Try
Process.Start(Directory)
Catch ex As Exception
MsgBox(ex.Message & " " & System.Reflection.MethodBase.GetCurrentMethod.Name)
End Try
End If
End If
End If
Next
End If
Catch ex As Exception
MsgBox(ex.Message & " " & System.Reflection.MethodBase.GetCurrentMethod.Name)
End Try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment