Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
DataGridView1.Columns(1).Visible = True
ElseIf CheckBox1.Checked = False Then
DataGridView1.Columns(1).Visible = False
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
DataGridView1.Columns(2).Visible = True
ElseIf CheckBox2.Checked = False Then
DataGridView1.Columns(2).Visible = False
End If
End Sub
Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox3.Checked = True Then
DataGridView1.Columns(3).Visible = True
ElseIf CheckBox3.Checked = False Then
DataGridView1.Columns(3).Visible = False
End If
End Sub
Function ComposeSQLToPrintSpecial4Keng() As String
Dim SQLBuilder As System.Text.StringBuilder = New System.Text.StringBuilder()
IF (CheckBox1.Checked) Then
SQLBuilder.AppendLine( ",[Column01] ")
End IF
IF (CheckBox2.Checked) Then
SQLBuilder.AppendLine( ",[Column02] ")
End IF
IF (CheckBox3.Checked) Then
SQLBuilder.AppendLine( ",[Column03] ")
End IF
SQLBuilder.AppendLine( "SELECT [ColumnA] , .... " & SQLBuilder.ToString() )
SQLBuilder.AppendLine( "FROM [TABLE_NAME]")
SQLBuilder.AppendLine( "WHERE .... ")
SQLBuilder.AppendLine( "ORDER BY ..... ")
Return SQLBuilder.ToString()
End Function
คุณให้ข้อมูลมาเท่านี้ก้อเท่านี้แหละค่ะ
Comment ทั้ง 3 CheckedChanged เดิมออกไป
ใส่ปุ่ม SUBMIT เอา CODE นี้ไปดัดแปลง สร้าง DATASOURCE
แล้ว BIND กะ GRID ดูก่อนก้อได้ อ้อตั้ง Auto Generate column ไว้ด้วยค่ะ
ถ้า grid ok ตัว report ก้อ ok