Two tab tips free of charge!-VBForums
Results 1 to 6 of 6

Thread: Two tab tips free of charge!

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2016
    Posts
    42

    Two tab tips free of charge!

    OK, so I am a newbie programmer and am enjoying it very much, but made a rookie mistake. I had built a form that looked and acted exactly as I wanted it to. It is a two tab form so users would enter data in the first tab, then switch to the second tab to see the results of the data entry. I had the user click on a button on the second tab to calculate and display the results in a datagridview. Since the data changes each time the user makes changes, why make the user click on the button to see the changes. Why not have the program compute the data when the user moves to the second tab. So I decided to fix it. I looked up an example on the internet and added a new tab to try it out. It worked perfectly, so I deleted the third tab....

    First Tip! Do not hit the delete key on the tab control itself. This will delete the tab. Go to the collections button on the properties box to delete the tab. Lesson one learned. (I know this isn't worthy of a post, but wait'll tip two.)

    Second Tip! I panicked and hit control Z and got my tab control back. The problem that I had was the main data entry was blank with a couple of labels and text boxes. I opened the form designer and all of the controls were listed, but I could't see them. I tried to create a new button with the same name, but it would't allow it. The error I got was that the button already existed. I knew my controls were there, just couldn't see them. After looking all over the internet for a solution, I realized what the problem was.

    An example of the form is shown below. It has 20 buttons numbered 1 through 20. The user clicks on a button, the data is added to a file, the button turns red and is disabled until the file is saved and the next round of data is added. In order to make it look nicer, I added two text boxes of different colors to add a border around the buttons, each being a different color. As you can see, the buttons are blue, the first background is yellow and the second background is black. (This is just a partial screenshot, I keep the form beneath the text boxes white for other reasons). When I hit control z, it moved the order of of the buttons and text boxes. The yellow was forward, the black was second and the buttons were in the back hidden by the forms. All I had to do was to move the order of the controls to what they were originally and I am back in business.
    There were many posts about this subject,but none of them that I read had this solution.
    I appreciate this forum and wanted to contribute a tiny bit to it.

    Thanks


    Name:  TankEntry.jpg
Views: 115
Size:  28.3 KB

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    30,836

    Re: Two tab tips free of charge!

    Did you really use textboxes as backgrounds? How about just using a panel. That would likely be easier.

    It sounds like this might all be due to how the controls are organized in the form. Every control is in the Controls collection of some container. Controls directly on the form are in the Controls collection of the form, controls directly on a tab are in the controls collection of the tab. It sounds like you have controls in the tab, but overlapping one another. If that's the case, then the order of the controls will have a pretty significant impact on the rendering. However, since EVERY control has a Controls collection, it might make more sense to have the top control IN the bottom control, rather than just having it overlap.

    You might also want to look at the Document Outline view, which is found in View | Other Windows.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2016
    Posts
    42

    Re: Two tab tips free of charge!

    I hadn't learned about panels yet. Textboxes were handy and filled the bill (I guess for position).

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    30,836

    Re: Two tab tips free of charge!

    Nearly anything works in most cases. Every control on a Windows form is a Window. The difference between the controls really comes down to how they react to user actions and how they draw themselves. I think you might be able to use pretty nearly any control as a colored background object. Still, some may be better for that simply because they were sort of made with that in mind. Only sort of, though.
    My usual boring signature: Nothing

  5. #5
    Fanatic Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    976

    Re: Two tab tips free of charge!

    Cheers!

    Good job! Yes you could have used something easier to work with but, that will do.

    Another thing you could have done was went over to paint and made your own background image using shapes and filling it in then going to the background image property (The name can vary sometimes) and set it to that image.

    I don't use the tabcontrol itself instead I use a custom one to make the tabs look like webbrowser tabs with "X" on them, when the user clicks the "X" the tab is closed.

    I am working on a tutorial guide and will have it out soon, I will let you know when I do, as you seem to like learning programming.

    Also the tab control I mentioned is here: https://github.com/jdc20181/BeffsBro.../TabControl.vb

    You make a new class I named mine Tabcontrol, and add the code you will need to add the import stuff above the class name.

    Build your project and look in your toolbox you should see your new control.

    It uses the same properties as the tabcontrol but with the custom functions mentioned.

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2016
    Posts
    42

    Re: Two tab tips free of charge!

    Thank you for your kind words and encouragement. I am looking forward to your tutorial since the tab I am using is rather bland and lifeless.

    Best of luck
    Carroll

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.