Skip to content

Instantly share code, notes, and snippets.

View NPS-ARCN-CAKN's full-sized avatar

NPS Arctic and Central Alaska Inventory and Monitoring Networks NPS-ARCN-CAKN

View GitHub Profile
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / GridEXLoopThroughTable.vb
Last active September 26, 2017 20:39
GridEX: Loop through table (VB)
'Loop through the rows
Private Sub DumpGridEXTable(GridEX As GridEX)
For Each Row As GridEXRow In GridEX.GetRows
Debug.Print("GroupValue: " & Row.GroupValue)
For i As Integer = 0 To Row.Cells.Count - 1
Debug.Print(vbTab & Row.Cells(i).Column.Caption & " " & Row.Cells(i).Value)
Next
Next
End Sub
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / GridEXDefaultValues.vb
Last active October 11, 2017 16:02
GridEX: Set column default values on the fly.
'root table
Private Sub CampaignsGridEX_SelectionChanged(sender As Object, e As EventArgs) Handles CampaignsGridEX.SelectionChanged
Me.TblVitalSignWorkLogGridEX.RootTable.Columns("LogDate").DefaultValue = Now
End Sub
'heierarchical tables
Private Sub CampaignsGridEX_SelectionChanged(sender As Object, e As EventArgs) Handles CampaignsGridEX.SelectionChanged
Me.CampaignsGridEX.Tables("Campaigns").Columns("RecordInsertedDate").DefaultValue = Now
Me.CampaignsGridEX.Tables("Campaigns").Columns("RecordInsertedBy").DefaultValue = My.User.Name
End Sub
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / LoadGridEXDropDownColumn
Created September 15, 2017 21:31
Load a Janus GridEX DropDown column
'load the herd column dropdown
With Me.CampaignsGridEX.RootTable.Columns("Herd")
.HasValueList = True
.LimitToList = True
End With
Dim HerdList As GridEXValueListItemCollection = Me.CampaignsGridEX.RootTable.Columns("Herd").ValueList
HerdList.Add("Chisana", "Chisana")
HerdList.Add("Mentasta", "Mentasta")
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / CreateDataTable.vb
Created September 7, 2017 21:20
VB .NET: Create DataTable
Dim MyDataTable As New DataTable
With MyDataTable
.Columns.Add("Name", GetType(String))
.Columns.Add("Age", GetType(Integer))
.Rows.Add("Sketr", 24)
.Rows.Add("Big Guy", 8)
End With
For Each Row As DataRow In MyDataTable.Rows
Debug.Print(Row.Item("Name") & Row.Item("Age"))
Next
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / DataBoundCodeTranslatingDataGridViewComboBox.vb
Created September 7, 2017 15:57
VB .NET: Set up a data bound, code translating DataGridViewComboBox
Private Sub LoadWorkLogNetworkIDComboBox()
'get a reference to the datagridview's combobox column
Dim NetworkIDCombobox As DataGridViewComboBoxColumn = Me.TblNetworkWorkLogDataGridView.Columns("WorkLog_NetworkIDComboBox")
'set the combobox's datapropertyname to the corresponding column in its bindingsource. this bindingsource was set up using the form's tools, not in code
With NetworkIDCombobox
'bind the combobox to the NetworkID column of the work log bindingsource's datatable
.DataPropertyName = "NetworkID"
'load the combobox options from a database query
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / MasterDetailDataGridviews.vb
Created July 27, 2017 19:40
Synchronized master-detail DataGridViews tip
'Use this tip if you have a .Net DataSet with two or more tables that have a master-detail relationship and you want to show the master data in a DataGridview and the related detail records in another DataGridview.
'This tip assumes you've used the DataSet Wizard and have that all set up. The master DataGridView is easy to set up, just point it to the Dataset and Table you want. To get the detail DataGridView to synchronize with the master you need to set the underlying table's BindingSource's DataSource property to the foreign key relationship of the master table's BindingSource.
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / DetailsFormDefaultModeByQueryString.vb
Created July 21, 2017 20:39
ASP .Net VB DetailsForm - Set DefaultMode on Page_Load using QueryString parameter
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Request.Params("CampaignID") = Nothing Then
'There is no record to edit, set the form to Insert mode
Me.DetailsView1.DefaultMode = DetailsViewMode.Insert
Else
'User requested a Campaign record to view
Me.DetailsView1.DefaultMode = DetailsViewMode.ReadOnly
End If
End Sub
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / GetDataTable.vb
Created January 5, 2017 15:35
VB .Net: A function to return a DataTable from a database connection.
''' <summary>
''' Returns a DataTable from a database query defined by a ConnectionString.
''' </summary>
''' <param name="ConnectionString">ConnectionString to a database</param>
''' <param name="Sql">An SQL query</param>
''' <returns>DataTable</returns>
Private Function GetDataTable(ConnectionString As String, Sql As String) As DataTable
'the DataTable to return
Dim MyDataTable As New DataTable
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / VB .Net Set Up DataGridView Default Values.vb
Created January 3, 2017 17:52
VB .Net Set Up DataGridView Default Values
'https://msdn.microsoft.com/en-us/library/b22t666e(v=vs.110).aspx
Private Sub dataGridView1_DefaultValuesNeeded(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) _
Handles dataGridView1.DefaultValuesNeeded
With e.Row
.Cells("Region").Value = "WA"
.Cells("City").Value = "Redmond"
.Cells("PostalCode").Value = "98052-6399"
.Cells("Country").Value = "USA"
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / GitCertificateFix.bat
Last active December 29, 2016 22:16
Git certificate fix
git config --global http.sslCAInfo "C:\PathToCertificate.crt"