Strongly Named Key

Bind a Combo or ListBox to an Enumeration

While this works, most Enum are in Camel case and do not have spaces, which may not be what you want

ComboBox1.DataSource = System.Enum.GetValues(GetType(PeopleNames))

Dim nameid As PeopleNames = CType(ComboBox1.SelectedValue, PeopleNames)

Note there should be no need to set the DisplayMember. If it does not work check that you have nothing on the control > DataBindings > Text binding

The variable “nameid” contains a 0, or 1, or 2 etc. depending on the value of the enumerated item that is currently selected.

May also bind to VS enumerations. Good use would be to bind to

ListBoxChartType.DataSource = System.Enum.GetValues(GetType(System.Windows.Forms.DataVisualization.Charting.SeriesChartType))

 

sender Is (control) with Option Strict On

 
Select Case True
    Case sender Is PrintPreviewToolStripMenuItem, sender Is PrintPreviewToolStripButton
 
From
You can use Select Case as in the following:

Select Case True
   Case sender Is TextBox1
      Label1.Text = TextBox1.Text
  
Case sender Is TextBox2
      Label1.Text = TextBox2.Text
End Select

However, this translates into IL (and decompiled using Reflector) as:

 Dim flag1 As Boolean = True
      If (flag1 = (sender Is Me.TextBox1)) Then
            Me.Label1.Text = Me.TextBox1.Text
      Else
            If (flag1 = (sender Is Me.TextBox2)) Then
                  Me.Label1.Text = Me.TextBox2.Text
            End If
      End If

I don’t know if this helps.

METHOD How to set a Local Report Parameter

 

They said it could not be done.
But here is the code to set a Local Report Parameter at runtime

”’ <summary>
”’ METHOD How to set Report Parameter
”’ </summary>
”’ <param name="MyReportViewer"></param>
”’ <param name="sParameterName"></param>
”’ <param name="sParameterText"></param>
”’ <remarks></remarks>

Private Sub SetLocalReportParameter(ByVal MyReportViewer As Microsoft.Reporting.WinForms.ReportViewer, ByVal sParameterName As String, ByVal sParameterText As String)

Try
Dim rp As New ReportParameter(sParameterName, sParameterText)
Dim rpP() As ReportParameter = {rp}
With MyReportViewer
.LocalReport.SetParameters(rpP)
.RefreshReport()
End With

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

End Sub

Report does not refresh with BindingSource Filter

 
For a local report, where you want to refresh based on the BindingSource. See this link.
 
 
Required code is
 
Dim tempBindingSource As New BindingSource(Me.OriginalBindingSource, "")
Me.ReportViewer1.LocalReport.DataSources(0).Value = tempBindingSource
 
Steve

Print DataGridView

 
 
Place for feedback on visual studio is …
 
 
for Print + DataGridView see 88229 from
 

Late Binding when reference not available E.g. Excel

VB.Net Starter

Dataset and SQL Computed Columns

 
If adding a table which contains computed columns to a dataset, then the dataset generated update and insert statements mistakenly include these computed columns in their SQL.
 

Datagridview Multi-Page Printing

 
Contacted Eric Nelson of Microsoft this week, I am hoping to promote microsoft progression of a version of this feature