Options Form Example

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
8 posts Page 1 of 1
Contributors
User avatar
bisnes_niko
Serious Programmer
Serious Programmer
Posts: 409
Joined: Tue Aug 24, 2010 1:21 pm

Options Form Example
bisnes_niko
What are we going to learn now?

I am going to show you how-to make options form like the one you see below with all functions (Expect saving settings, loading...)

This is what we will end up to:
preview.png
First of to begin, you need 1 list box and couple panels (3).

Name the list box as
Code: Select all
lstSettings
For panels, you don't need to name them. Just add tag for each panel, like General, Updates, User-Interface.

Add whatever controls you want to add them.

Copy and Paste this explained text into your project (I'm not sure if you need to change your form name as frmOptions)
Code: Select all
Public Class frmOptions

    Private Sub frmOptions_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ' // Select the first item

        lstSettings.SetSelected(0, True)

    End Sub

    Private Sub lstSettings_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstSettings.SelectedIndexChanged

        ' // Our functions are in that sub

        ChangeSettingsPanel()
    End Sub

    Public Sub ChangeSettingsPanel()

        ' // Scan all items

        For i = 0 To Me.Controls.Count - 1

            ' // Less writing

            With Me.Controls

                ' // We don't want items that has no tag
                ' // We have given our panels a tag through properties

                If .Item(i).Tag = "" Then

                Else

                    ' // If the tag isn't empty, then check if the list box has selecteditem text
                    ' // same as the panel tag

                    If lstSettings.SelectedItem = .Item(i).Tag Then

                        ' // Then set the properties to show it and also don't forget to 
                        ' // edit the size


                        ' // Location

                        .Item(i).Location = New Point(146, 12)

                        ' // Size

                        .Item(i).Size = New Size(323, 290)

                        ' // And last, show the panel

                        .Item(i).Show()

                    Else

                        ' // If the panel tag isn't lstSettings selectedItem then
                        ' // Hide it, no need to resize.

                        .Item(i).Hide()

                    End If

                End If

            End With
        Next

    End Sub


    Private Sub btnSaveSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveSettings.Click

        ' // Save settings through My.Settings or to a textfile.

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click

        ' // Close without saving settings

        Me.Close()

    End Sub
End Class


I also have 2 buttons:
Code: Select all
 btnCancel
 btnSaveSettings
That should be it, for me, it works like a charm. If the no panel tagged as lstSettings SelectedItem then the form will look quite empty, so double check your items and panel's tags


Heres the source code for what you see on the image above.
Source (WinRar required):
vbNet Options Form Design Example.rar
You do not have the required permissions to view the files attached to this post.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Options Form Example
Dummy1912
Thanks for sharing Machard
:D
or you gonna post a update too?

Dummy1912
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
bisnes_niko
Serious Programmer
Serious Programmer
Posts: 409
Joined: Tue Aug 24, 2010 1:21 pm

Re: Options Form Example
bisnes_niko
Dummy1912 wrote:
Thanks for sharing Machard
:D
or you gonna post a update too?

Dummy1912

Update? May I ask for what?
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Options Form Example
Dummy1912
if you made any change's or something :D
thats what i mean with a update.

Just a question not a request :D

Dummy1912
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Skillful
Skillful Coders
Skillful Coders
Posts: 969
Joined: Tue Nov 16, 2010 10:07 am

Re: Options Form Example
Skillful
Nice tutorial. I'll use it for one of my apps.
Instead of LOL use this -
LSIBMHBIWFETALOL

Which means -
Laughing silently in between my head because it wasn't funny enough to actually laugh out loud!
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: Options Form Example
GoodGuy17
Can you explain what this does, because I don't really like just copy and paste, and this looks handy. So can you explain the code for each event/function, and what it does?
User avatar
bisnes_niko
Serious Programmer
Serious Programmer
Posts: 409
Joined: Tue Aug 24, 2010 1:21 pm

Re: Options Form Example
bisnes_niko
GoodGuy17 wrote:
Can you explain what this does, because I don't really like just copy and paste, and this looks handy. So can you explain the code for each event/function, and what it does?

Just download and examine the source, how could I explain it more...

You have different sections for settings, like general settings... (then you put there like, Launc when Window Starts checkbox, and so on...) That should explain little bit

Download and examine
User avatar
iLenkaa
Top Poster
Top Poster
Posts: 170
Joined: Mon Nov 01, 2010 1:17 pm

Re: Options Form Example
iLenkaa
Nice tutorial! :')

Btw: Download 7zip to extract .rar (it's free!)
Image
Image
Image
Image
Image
Image
8 posts Page 1 of 1
Return to “Tutorials”