kayton
kayton

Reputation: 3759

How can I make a C# UI remove Panel Controls using a button listener (basically)?

Okay, so I have a database project for my database class. I have a database made in MySQL and am making my application in C#. The database is basically just a parts database, in 4NF consisting of parts, relational tables, build, customer, and order tables as this is for a customer-based computer build database. I have no problems with the way my database is designed or anything but I'm wondering how I should do my GUI for such a thing.

I currently have it setup in tabs and each tab is a part needed in the build but I'm not liking the way it looks. Is there a way that I could have Next and Previous buttons and have a Pane for each part and step through them? I'm somewhat new to C# and am trying to learn. Suggestions?

EDIT: I guess I should make it clear that I'm looking at possibly using Panels and switching through them using Next and Previous buttons opposed to using tabs and iterating through those.

EDIT2: I didn't figure out a way to do it by changing the view to a new Panel but I figured out how to do it by dynamically adding/removing data. Here's what I want - A way to store buttons, labels, and all other Controls needed within a Panel and be able to change the Panel being viewed within a Form...all by the click of a button.

Upvotes: 1

Views: 250

Answers (3)

kayton
kayton

Reputation: 3759

I successfully achieved what I wanted to. I have a class for each layout for each screen for each computer part I need. This class is a subclass of Panel. All of these Panel subclasses take on controls within them (button, textbox, label, etc) and the indices of each Panel are stored within variables in each class. These variables say what "page" you're viewing and which page comes next/previous with respect to your current location. Then, the main thing I was missing, is the z-order. To change the z-order when doing next/previous buttons, I use the following:

Controls.SetChildIndex(PartLayout,0); //this sets the PartLayout Panel (Extended)
                                      //to the 0 index or the front/visible layer

That's basically it. I haven't actually implemented what I specifically wanted yet but I've done so with a test file and got it to do what I wanted. Thanks everyone for your help!

Upvotes: 0

KeithS
KeithS

Reputation: 71573

You could have Previous/Next buttons quite easily. I would place them outside the TabControl (so you're not duplicating them) and then have their handlers simply increment or decrement the SelectedIndex property of the TabControl.

EDIT: Are you aware that you can make tabs not look like tabs? You can set the Appearance property to TabAppearance.Buttons, for instance, and the "tabs" will instead be rendered as buttons, which would make the tab row look more like a breadcrumb control.

You can also use Panels overlapped on the Form, and call the BringToFront() method of the Panel representing the Page you want.

Upvotes: 0

David
David

Reputation: 73574

I don't have a complete answer for you, but I do have a suggestion.

There are some very nice videos and tutorials on building data access forms at windowsclient.net/learn/videos.aspx Most of them are short, to the point, and very useful. I'd look at a few and see if any looks interesting.

With the "next/previous" buttons you're talking about "paging". I don't know off the top of my head how to do that in WinForms, but this would be the first place I'd look.

Upvotes: 4

Related Questions