VB.net Form not displaying controls

I have created a windows form based on a C# coded app.  I am translating to VB.  The appl will consist of a few different forms but in translation I am having a problem with the controls appearing on the form.  Right now I have a main form with a button that will show the ManagePermissions form.  

I have attached the code for the ManagePermissions form.  When I click the "Show Permissions" button on the main form my form comes up blank.  

Thanks in advance ManagePermissions.txt
rommelitAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rommelitAuthor Commented:
Any thoughts out there? I know it's the holidays but perhaps someone could pop a suggestion up.
0
rommelitAuthor Commented:
I have played with this a bit and I think it's an issue with the InitializeComponent sub.  Everything I read points to the fact that the VB designer should be automating the InitializeComponent sub.  Perhaps I translated something wrong when I converted C# to VB?
0
ElrondCTCommented:
What version of Visual Studio are you using? VS 2005, 2008, 2010? I'm trying to replicate this, but it's hard without the resources file (.resx).
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

rommelitAuthor Commented:
Elrond - VS2008.  You can download from here.  You will need to create the DB and change connection strings with the text file inside the project folder.  Apptly named "Copy of ControlSecurity.sql"
0
ElrondCTCommented:
I'm also using VS 2008. Once I found all the occurrences of the SQL connection string and redirected them to my server, everything ran correctly. I can see the ManagePermissions form with its controls on it, though I'm not seeing anything in the Role Name or Current Status blocks, and the RolesBindingNavigator is inactive because it shows no records. However, you didn't give me any records for the SQL database; I have the structure only.

Be that as it may, I'm seeing the controls on the ManagePermissions form, while you're not. It certainly is problematic to mess with the InitializeComponents sub, and such changes are prone to be overwritten. But what you have seems to work properly. When I first got your text file, I wondered if the problem was that your InitializeComponents was in the .vb file, rather than the .designer.vb file, but that's not an issue in the full solution you sent.
0
rommelitAuthor Commented:
So the form loads with all controls and reads the DB correctly?  I am getting an error when clicking Button1 "Column 'ControlID' does not belong to table controlsToRoles."
0
ElrondCTCommented:
I didn't get that error when the database was empty. Once I entered some data I got the same error, but that makes sense, because the column name in controlsToRoles is FKControlID. However, that's actually a misleading error message; the datatable that's being loaded is actually Roles. Your queryString definition is at issue; first you define it, then you're overwriting it in the "If ByControlRB.Checked" decision tree. I think you probably want the ORDER BY appended to the first string; I'm not sure what the Else is supposed to result in. So it should probably be something like:

If ByControlRB.Checked Then
            queryString &= "ORDER BY ControlID"

Note the & just before the =, which means add the new text to the end of the existing text.

Your use of "&" between two literal text strings doesn't make any sense; is something else supposed to go in the middle? In your original queryString definition, it would make no difference if it were all one long string, with the ampersands (and related opening and closing quotes) removed. What is your intention here?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rommelitAuthor Commented:
I removed the literal text strings as I was playing with the code.  The correct code should have been similar to the order by ControlID but instead of ControlID I would sort by RoleName.

Here is the end game.  I want to perfect this test application and integrate it into a larger program. (This is actually a test app hence the sloppy code).  I have been trying to develop a security interface that allows Admins to enable and disable features based on the role then assign users to that role.  (I am not tying the app to a domain hence why I am not using iPricipal.)

Does this make sense?
0
ElrondCTCommented:
OK, so the idea is that a particular control (textbox, checkbox, etc.) is usable by certain people and not others, based on the role they are assigned to. That seems like a reasonable idea. Your application would then read the database when a user logs in, and enable/disable/hide controls based on what is in the database.

If you change the IF statement as I showed in my prior post, and turn on the ByControlRB radiobutton, ManagePermissions loads properly. The current code doesn't seem to be enough to add new records. But we're a long way from a form coming up blank.
0
rommelitAuthor Commented:
No.  I have other code I am working on for the events you speak of.

Before I close; can you advise as to why the PermissionTree doesnt populate properly?
0
ElrondCTCommented:
What do you mean by not populating properly? Once I fixed queryString, I'm getting entries in PermissionTree for each row in ControlsToRoles.
0
rommelitAuthor Commented:
I get the role 'Limited" but it only lists 'enabled'  where it should list the role and control description.  An example would be:
Button1: visible and enabled

It's part of this code:
PermissionTree.BeginUpdate()
        PermissionTree.Nodes.Clear()
        Dim parentNode As TreeNode = Nothing
        Dim subNode As TreeNode = Nothing

        Dim currentName As String = String.Empty
        For Each row As DataRow In dt.Rows
            Dim subNodeText As String = If(ByControlRB.Checked, row("RoleName").ToString(), row("ControlID").ToString())
            subNodeText = ":"
            subNodeText = If(Convert.ToInt32(row("Invisible")) = 0, " visible ", " not visible ")
            subNodeText = " and "
            subNodeText = If(Convert.ToInt32(row("Disabled")) = 0, " enabled ", " disabled ")

            subNode = New TreeNode(subNodeText)
            Dim dataName As String = If(ByControlRB.Checked, row("ControlID").ToString(), row("RoleName").ToString())
            If currentName <> dataName Then
                parentNode = New TreeNode(dataName)
                currentName = dataName
                PermissionTree.Nodes.Add(parentNode)
            End If

            If parentNode IsNot Nothing Then
                parentNode.Nodes.Add(subNode)
            End If
        Next
        PermissionTree.EndUpdate()
0
ElrondCTCommented:
You've got the same problem of overwriting rather than appending text; change all the "subNodeText =" to "subNodeText &=" and I think you'll like the results much more.
0
rommelitAuthor Commented:
Probably the most help I have ever received from an Expert!  Thanks for paying it forward to a novice just trying to learn.
0
ElrondCTCommented:
Glad to help. I've been in your shoes...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.