| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: Newbie help with List |
That is exactly what I am trying to do !
Thanks for the help!!
Chris B
"Visual Basic Wizard" wrote
in message news:...
> I assume you are trying to set up a tabular list with the fields spread
> across three columns. Unfortunately, you cannot use a standard listbox this
> way. If you set up a listbox with columns, the items will fill the
> left-most column first, then fill the next column rightward, etc.
>
> You need to use a listview control, which is part of the "Microsoft
> Windows Common Controls 6.0" custom control. You'll need to set the
> following properties to set up the control [hint: use the (custom) property
> sheet to do this]:
>
> General tab:
> View: 3-lvwReport
>
> Column Headers tab:
> Click on "Insert Column" button.
> In the text field enter the name of the field.
> Do this for the other two fields.
>
> This will set up the listview with 3 columns and the headers will
> contain the names of the fields.
>
> To populate the list you just have to read in the records from the
> database. The Recordset object contains a collection of Field objects that
> contain the fields from the database. The Field objects have a Value
> property that contains the value of the record. To access a specific record
> use this form:
>
> recordset_object.Fields("Field Name").Value
>
> Here's an example of how to read in the fields. lvwRecords is the name
> of listview control:
>
> ----------------------------------------------------------------------------
> -----
> ' Code snippet showing how to populate a listview control from a database
> table
> ' Declare variables and objects
>
> Dim rsRecords as Recordset ' Reference to recordset
> Dim liNew as ListItem ' Item in a listview control
>
> ' Set the reference to the database objects
> [Database stuff here]
>
> ' Read in the database records
> Do Until rsRecords.EOF
>
> ' Create listitem object
> Set liNew =
> lvwRecords.ListItems.Add(Text:=rsRecords.Fields("fname").Value)
>
> ' Populate the other columns
> liNew.ListSubItems.Add Text:=rsRecords.Fields("lname").Value
> liNew.ListSubItems.Add Text:=rsRecords.Fields("id").Value
>
> ' Move to the next record
> rsRecords.MoveNext
>
> Loop
>
> ' Cleanup object reference
> Set liNew = Nothing
> ----------------------------------------------------------------------------
> -----
>
> Hope this helps.
> --
> Said the option button to the window: "I've been framed!"
>
> Dan Rushe
> visualbasicwizard{at}comcast.net
>
> "Chrisb" wrote in message
> news:73bd8c3d.0405211520.759744d0{at}posting.google.com...
> > I need a little help with an sql query and a listbox.
> > My query is basically this:
> >
> > Dim conn as New connection
> > Dim strsql as new recordset
> > Dim sql as string
> > Conn.Open (database stuff) <<<---just for simplicty here
> > sql = "Select fname, lname, id from ppl"
> > set strSQL=Conn.Execute (sql)
> > list1.additem strSQL <<<< * Origin: MoonDog BBS, Brooklyn,NY, 718 692-2498, 1:278/230 (1:278/230)SEEN-BY: 633/267 270 @PATH: 278/230 10/345 106/1 2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.