Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check box in a grid or list box?

Status
Not open for further replies.

stnkyminky

Programmer
Oct 15, 2001
476
US
Check box in a grid or list box?
Is this possible with standard VB6 controls? Scott
Programmer Analyst
 
I also need the contents to display like this:
CheckBox Data Data Data Scott
Programmer Analyst
 
I was able to use ListView for an application needing just such a data grid with checkboxes.

N.B. A crucial part turned out to be setting the control's view to lvwReport. In this example the first data column and the checkbox are part of the same column. It wasn't a big deal for me, but you could probably create a blank column first to make it even cleaner.

--Mark


Following is the code:


Private Sub FillListView()
Dim strSql As String
Dim rs2, rsCurrSet As Recordset
Dim strCode, strUpdate, strName As String
Dim itmX As ListItem
Dim dteDate, dteArchive As Date

lsvExport.ColumnHeaders. _
Add , , "Quote Accepted", lsvExport.Width / 4
lsvExport.ColumnHeaders. _
Add , , "Last Updated", lsvExport.Width / 4, _
lvwColumnCenter
lsvExport.ColumnHeaders. _
Add , , "Insured Name", lsvExport.Width / 2

lsvExport.View = lvwReport

On Error GoTo cantSearch

strSql = "Select ArchiveDays From AQFOptions"

Set rsCurrSet = dbAQF.OpenRecordset(strSql, dbOpenSnapshot)
rsCurrSet.MoveFirst
dteArchive = rsCurrSet("ArchiveDays")

rsCurrSet.Close
Set rsCurrSet = Nothing

dteDate = DateAdd("D", -(dteArchive), Now)

strSql = "SELECT Quote.Number, LastUpdate, Name1 " & _
"FROM Quote INNER JOIN Insured ON Quote.InsuredNumber = Insured.Number Where quote.exported = false and (Quote.LastUpdate >= #" & dteDate & "#)"

Set rs2 = dbAQF.OpenRecordset(strSql, dbOpenSnapshot)
If rs2.RecordCount > 0 Then
rs2.MoveFirst

While Not rs2.EOF
Set itmX = lsvExport.ListItems. _
Add(, , " " & CStr(rs2!Number)) ' QuoteNumber.

' If the AuthorID field is not null, then set
' SubItem 1 to it.

itmX.Checked = True

itmX.SubItems(1) = CStr(rs2!LastUpdate)

itmX.SubItems(2) = rs2!Name1



rs2.MoveNext ' Move to next record.
Wend

rs2.Close


End If


Exit Sub
 
itmX.SubItems(1) = IIf(IsNull(db.Project_rs("trailer_id")), "", db.Project_rs("trailer_id"))

I rcving an invalid property use on this line of code? Scott
Programmer Analyst
 
HuskerMark,
I've applied your solution and it is working beautifully.

Thanks for your help.

P.S. I rcvd the error above because I didn't have additional columns defined. Scott
Programmer Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top