ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Visual Basic .NET - Can I make a dynamic GUI?

(1/3) > >>

wreckedcarzz:
Does anyone know if it is possible to make a drag-and-drop GUI, configurable on-the-fly by the user? Something like this...

User starts program
Program window opens, awaits action
User clicks Button1 to execute action XYZ. After execution the user returns to the program.
User right clicks on Button1, and drags Button1 to a new location
The user closes the program (optional)
Program saves custom GUI item locations
User starts program (if program was closed)
Program window opens, loads the GUI item locations, adjusts items accordingly, and awaits user action
User clicks Button1 as if it were positioned originally (from in the VB designer) and action XYZ executes.

To be totally honest, I expect this to be very complicated and use a lot of code, and on top of that I have absolutely no idea how to save settings (I am going to go Google-mad after this post and begin researching on Setting saving and loading). But, I figure it is worth a shot to ask! Can't know until you try, right?

If anyone understood any of the ideal end-user steps above, and could help me with this in any way, please help me understand how I would go about doing this :)

PPLandry:
I can definitely be done, I've done exactly that using VB3 15 years ago and it wasn't complicated to do...

[edit]

* You basically put an invisible copy of every control type you want (textbox, commandbutton, radiobutton, etc)

* When the user does the right thing, you programmatically copy the invisible one to a new visible one

* You save the configuration to a text file. I used tab-delimited (now may be more convenient to use XML format)

* On re-open, you re-create the controls based on this file

* To switch between design and run modes, simply change the dragmode properties
If you want sample code, just ask.

CWuestefeld:
Dynamically creating and moving controls in .Net is trivial -- look at the code that the designers generate for you, and you can see that this is exactly what it's doing.

What will be more complicated is keeping the user from being confused as you switch modes from making the button actually click as it's designed vs. making it grab-able and dragable.

And BTW, if you find examples of this for C#, it's pretty much exactly the same for VB. Other than the syntactic differences, the way you handle the WinForms framework isn't dependent on the calling language.

wreckedcarzz:
I don't really understand what you are saying PPLandry (I get the idea, just not how to execute it). I know how to make invisible controls, but the copying I don't "get". I am getting a feel for saving settings right now (reading several examples and searching), but I don't know how to actually move the items while the program is running (I don't see what you mean by "look at the code", CWuestefeld - I have done it before where it gives me an XML type of data sheet, but I can't get it to do it now; could you elaborate as to how to get that info?).

I will Google for examples though. Didn't know about that.

PPLandry:
I would have to look up how to do it in .net, but in plain old VB, your invisible control is a control array. So you simply do ControlName.add. This can help:
http://visualbasic.about.com/od/usingvbnet/l/bldykctrlarraya.htm
http://msdn2.microsoft.com/en-us/library/aa289500.aspx

Navigation

[0] Message Index

[#] Next page

Go to full version