Click here to Skip to main content
15,847,077 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys! I'm a total noob when it comes to this. I have searched online and found a number of articles/guides about strings and substrings and I get the concept of it but I don't know if this is the correct way of implementing this. I've also seen that a number of people don't suggest saving multiple checkboxes into one field in the table. However, in this instance it would be necessary.

This is basically for a user access menu and additional options. As you can imagine, there are many checkboxes so it's not feasible to create individual columns in the table for each checkbox.

This is for Winforms and C#

One set of checkboxes are all saved to the AccountUser table, AccessTable field.

Any guidance with code to save and retrieve the checkboxes would be appreciated!

What I have tried:

I haven't tried anything as of yet as I don't know how to best approach this. Any guidance would be appreciated.
Updated 14-Mar-21 23:47pm
Maciej Los 15-Mar-21 4:27am    
Sorry, but we can't read in your mind or direct from your screen... You need to provide more details.

1 solution

One set of checkboxes are all saved to the AccountUser table, AccessTable field.

This is wrong approach!

Imagine, you've got 4 menu items: {A, B, C D}.
There are 2 users in AccountUser table: {1, 2}, who can access menu items as follow:
[1] - {A, B, D}
[2] - {B, C, D}

So, you have to define another table to store menu items, which every user can access (User_Menu table):
UserId    MenuId
1         A
1         B
1         D
2         B
2         C
2         D

To get menu related to user #1:
FROM User_Menu
WHERE UserId = 1;

Finally, i'd suggest to read about authentication and authorization.
Here is sample implementation: Controls Based Security in a Windows Forms Application - Simple Talk[^]
Share this answer
Logan1980 15-Mar-21 5:41am    
Hi Maceij. Thanks for the info. I forgot to mention in my post that there is a table menu table like that already. I'm also already familiar with user based security roles etc. I've just never done anything in c# or winforms before. I'll have a look at the link. Thanks again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900