Tech Support > Computers & Technology > Programming > Dynamically using checkboxes in a listview
Dynamically using checkboxes in a listview
Posted by Tone Southerland on December 2nd, 2003


Maybe some of you guys can help me on this problem I'm having in VB
6.0. I have populated 2 listviews with information from 2 tables in a
database.

The first table (tblUserExes) has these fields:
1.UserRACF
2.ExeName

The Second table (tblUserNames) has these fields:
1.UserRACF
2.UserName


The relationship is one(tblUserNames) to many(tblUserExes) and they
are joined on the UserRACF field(which is an employee login id).

I am loading one of the listviews with all the UserNames in
tblUserNames, which only appear once. I am loading the other listview
with all of the ExeNames in tblUserExes which also only appear once.

This program will allow an adminstrator to grant or revoke access to
each user based on whether the checkbox is checked by the
corresponding ExeName. When the program starts up I want the first
name to be selected and all of the ExeNames that UserName has access
to to be checked.

Now my problem lies in how to tell the ExeNames in the listview that a
user has access to a particular program and how to mark that box as
checked. (I know how to set the checked property to true, that is not
what i am trying to get at here). For example if the UserName Mark is
selected in one of the listviews then all the programs he has access
to in the other listview will be checked.


I would also like to keep this information in 2 tables to re-enforce
integrity in my program to allow for better stability should this
program be used on a larger scale.


Any help is greatly appreciated on this...Thanx..Tone

Posted by Programmer Dude on December 5th, 2003


Tone Southerland wrote:

1. Trap the Item_Click event on the UserNames ListView.
2. Use the selected item to run a query against your database that
returns a recordset of the linked UserExes.
3. Use that recordset to check/uncheck the names in ExeNames ListView.

If you want to be able to *modify* the User/Exe links, it gets a lot
more complicated, since you'll need to update the UserExes table.
Probably the best way is to have a [Save] button on the ExeNames
Listview window that--when clicked--reconciles the displayed checks
to the underlying data.

--
|_ CJSonnack <Chris@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|


Similar Posts