Check box column as first column in grid

gjcoppens

New member
Joined
Apr 19, 2005
Messages
1
Location
green bay, WI
Programming Experience
Beginner
I am relatively new to this and need some assistance. I am working with a grid that is being populated by a dataset. The dataset is being "filled" via an SQL statement. What I can't do that I would like to do is add a first column to the gird that would be a check box. That column would allow the user to pick specific rows to be processed.

Here is my code thus far:

Option Strict On

Option
Explicit On

Option Compare Text

Imports
System

Imports System.IO

Imports System.Text

Imports System.Web.Mail

Imports System.xml

Imports System.Data.OleDb

Imports System.Runtime.InteropServices

Imports System.Configuration.ConfigurationSettings

Imports System.Reflection
Public Class Form1

Inherits System.Windows.Forms.Form

#
Region "Public Variables"

Public msSupportEmail As String

Public msConSS As String

Public mbVerboseLogging As Boolean

Public RMS As New RMSCommon.ClsCommon

Public dtmCurrentDate As Date = DateTime.Today

Dim sCarrierScac As String

Dim da As OleDbDataAdapter

Dim mconSS As OleDbConnection

#
End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

cboInboundOutbound.SelectedIndex = -1

cboFaxEDI.SelectedIndex = -1

MessageBox.Show(CStr(dtmCurrentDate))

End Sub
Private Sub btnGetLoads_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRetrieveLoads.Click

Dim ds1 As DataSet = New DataSet

LoadConfigSettings()

If Not mconSS.State = ConnectionState.Open Then

mconSS = New OleDbConnection(msConSS)

mconSS.Open()

End If

MsgBox("SCAC = " & CStr(txtCarrierScac.Text))

sCarrierScac =
CStr(txtCarrierScac.Text)

If sCarrierScac > " " Then

GetLoadsBySCAC()

End If

da.Fill(ds1, "TenderLoad")



DataGrid1.DataSource = ds1.Tables("TenderLoad")

End Sub

#Region "Database Access"

Private Sub GetLoadsBySCAC()

Dim sFleetScac As String

Dim sSelectOption As String

sFleetScac = txtCarrierScac.Text

sSelectOption = " tenderload.fleetscac = '" & sFleetScac & "'"

da =
New OleDbDataAdapter _

("Select distinct(LoadNbr), fleetscac, LoadOrientation as [Load Orientation], " _

& "OrigLocNbr as [Origin Loc], ts1.LocationName as [Origin], " _

& "ts1.Addr as [Origin Address], ts1.City as [Origin City], " _

& "ts1.State as [Origin State], ts1.Zip as [Origin Zip], " _

& "DestLocNbr as [Dest Loc], ts2.locationname as [Destination], " _

& "ts2.addr as [Dest Address], ts2.city as [Dest City], " _

& "ts2.state as [Dest State], ts2.zip as [Dest Zip] " _

& "from TenderLoad INNER JOIN TenderStop ts1 " _

& "INNER JOIN tenderstop ts2 on ts1.tenderid = ts2.tenderid " _

& "and ts1.stoptype = 'p' and ts2.stoptype = 'd' " _

& "on tenderload.tenderid = ts1.tenderid " _

& "and tenderload.tenderid = ts2.tenderid " _

& "and " & sSelectOption _

& " order by loadnbr", mconSS)

End Sub

#End Region

 
What you can do is add a new field (of type boolean) to the dataTable that is the source for the dataGrid. If you are using TableStyles (it doesn't appear that you are, but I include this for info purposes) you would have to include a DataGridColumn style of type DataGridBoolColumn for that new filed.
 
Back
Top