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 / Sql: Select distinct values into comma separated list.sql
Last active May 10, 2022 15:19
Sql: Select distinct values into comma separated list
DECLARE @Packs AS NVARCHAR(MAX)
select @Packs = STUFF((SELECT DISTINCT ',' + QUOTENAME(LTRIM(RTRIM(Pack))) from basequeryTotalPupsByRegion FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'),1,1,'')
select @Packs
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / GetCurrentGridEXCellValue.vb
Created August 23, 2019 17:13
Function to return the current cell value of a GridEX
''' <summary>
''' Returns the value of GridEX's current cell, if it exists, otherwise an empty string.
''' </summary>
''' <param name="GridEX">GridEX</param>
''' <param name="ColumnName">Name of GridEX cell to interrogate.</param>
''' <returns>String</returns>
Private Function GetGridEXCellValue(GridEX As GridEX, ColumnName As String) As String
Dim CellValue As String = ""
'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
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / AddItemToMultiColumnListViewItem.vb
Last active April 5, 2018 19:58
VB .NET: Add items to a multi-column ListViewItem
'Me.ItemsListView has two columns, one for the file name and one for the full file path
Dim FileAttributes(2) As String
FileAttributes(0) = FileInfo.Name
FileAttributes(1) = FileInfo.FullName
Dim ListViewItem As New ListViewItem(FileAttributes)
Me.ItemsListView.Items.Add(ListViewItem)
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / LoopSpecialFolders.vb
Created April 5, 2018 18:18
VB .NET: Loop through Environment.SpecialFolders
For Each SpecialFolder As Environment.SpecialFolder In System.Enum.GetValues(GetType(Environment.SpecialFolder))
Debug.Print(System.Environment.GetFolderPath(SpecialFolder))
Next
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / LoopThroughSpecialFoldersEnum.vb
Created April 5, 2018 18:02
VB .Net: Loop through an Enum (SpecialFolders)
For Each SpecialFolder As String In System.Enum.GetNames(GetType(Environment.SpecialFolder))
Debug.Print(SpecialFolder)
Next
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / GetMetadataDataTable.vb
Created January 2, 2018 22:38
A function to return a DataTable of metadata about a DataTable
''' <summary>
''' Returns a DataTable containing metadata about the structure of the submitted DataTable
''' </summary>
''' <param name="InputDataTable">DataTable to describe.</param>
''' <returns>DataTable</returns>
Public Function GetMetadataDataTable(InputDataTable As DataTable) As DataTable
Dim ColumnsDataTable As New DataTable("Columns")
'column names column
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / GetGridEXCellValue.vb
Created December 4, 2017 21:50
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
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / FilterReport.vb
Created November 13, 2017 17:38
VB .NET: Filter a report (windows forms)
'Put a report viewer on a form and build the report using the wizard
'Create a report parameter based on the filter criteria you would like to use. "IDReportParameter",22, for example to filter on ID=22
'In the report open the Tablix's properties and select Filters and set up the filter using the wizard
'In the master DataGridView's SelectionChanged (or other event) event add code similar to
Dim MyReportParameter As New ReportParameter("IDReportParameter", 22)
Me.WorkLogReportViewer.LocalReport.SetParameters(MyReportParameter)
Me.WorkLogReportViewer.RefreshReport()
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / GridEXDropDowns.vb
Last active October 13, 2017 19:30
Function to set up a GridEX column with dropdown values
''' <summary>
''' Loads distinct items from a DataTable's DataColumn into a GridEX GridEXColumn's DropDown ValueList
''' </summary>
''' <param name="GridEX">The GridEX containing the GridEXColumn requiring a DropDown ValueList</param>
''' <param name="SourceDataTable">Name of the DataTable containing the DataColumn from which distinct values will be drawn</param>
''' <param name="SourceColumnName">Name of the source DataTable's DataColumn from which distinct values will be drawn</param>
''' <param name="GridEXColumnName">Name of the GridEX column into which to load dropdown values</param>
Private Sub LoadGridEXDropDown(GridEX As GridEX, SourceDataTable As DataTable, SourceColumnName As String, GridEXColumnName As String, LimitToList As Boolean)
Try
'Ensure the GridEXColumn is configured for a DropDown
@NPS-ARCN-CAKN
NPS-ARCN-CAKN / GridEXSetup.vb
Created September 26, 2017 20:52
Set up a GridEX
Private Sub SetUpGridEX()
'create the Janus GridEX
Dim MyGridEX As New GridEX
With MyGridEX
.Name = DT.TableName & "GridEX"
.Dock = DockStyle.Fill
.DataSource = MyBindingSource
.BoundMode = BoundMode.Bound
.GroupByBoxVisible = True
.Hierarchical = False