Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   Dynamic form from text file. (http://www.programmingforums.org/showthread.php?t=13022)

randum77 Apr 19th, 2007 11:03 AM

Dynamic form from text file.
 
Ok, new one here. I've been trying to build a form from a text file. What I am trying to do specifically is when a form loads, it attaches to a txt file, reads it line by line, and build a radio button form based on it. This way, if we want to change the look of the form we can just update the txt file, rather then have to re compile the entire app.

What I've done so far is create the ioStreamReader and attached to the file. I was able to list the entire contents to a text box just to make sure the iostream was reading how I wanted it too. Now, i want it to read each line of the document, read to the first ", " and use that text as the app name, and everything after the comma as the path. For each line, i need a bullet w/ app name.

I was going to use a substring but i don't think it would do what I want, it would show the ", " and it's not dynamic enough. Also, i'm having a hard time brainstorming on the method to get the Radio button and lable to be generated at the procedure level. I've never done it before and am kind of lost. I know i'll also need to do an X and Y coordinate and increment it as well.

Well, any help is appreciated. I'll do some searches google and see what it shows. :)

randum77 Apr 19th, 2007 11:25 AM

I found this link with some information. Does it sound about right?

http://www.developerfusion.co.uk/forums/post/150908/

randum77 Apr 19th, 2007 12:14 PM

I found that the following code will make a radio button.

:

Dim rbYes As New RadioButton()
            rbYes = New RadioButton()
            rbYes.Left = 8
            rbYes.Top = 300
            Me.Controls.Add(rbYes)
            rbYes.Text = "YES"


The button will say YES next to it. Now, I have to figure out how to make it completely dynamic. I'm assuming I would use variable in all location possible, and on the Top and Left properties, i would increment them as needed. The only part that I wouldn't know right off is how to make the property name dynamic. The rbYes is what I mean. Would i declare it as rbYes(i) or something like that? I appreciate the help. :)

melbolt Apr 23rd, 2007 9:59 AM

Quote:

Originally Posted by randum77 (Post 126898)
The only part that I wouldn't know right off is how to make the property name dynamic. The rbYes is what I mean. Would i declare it as rbYes(i) or something like that? I appreciate the help. :)

well, you could give them names IF you knew how many you were going to have, then you could hardcode them in, but since you could have anywhere form 1 to 100, this is inconvenient, redundant, and not very efficient coding to do it this way.


instead, what you probably want to do is this, just keep adding them like so

:

  1.     rbYes = New RadioButton()
  2.                 rbYes.Left = 8
  3.                 rbYes.Top = 300
  4.                 Me.Controls.Add(rbYes)
  5.                 rbYes.Text = "YES"


now when you want to access it you can do something like this or some variation of it.

:

  1. 'iterate through every radiobutton control on the form
  2.         For Each rb As RadioButton In Me.Controls
  3.             If (rb.Checked) Then
  4.                 MsgBox(rb.Text & " was checked!!!")
  5.             End If
  6.         Next


you can also get to a control through its index (ex: me.controls(2))

randum77 Apr 24th, 2007 12:39 PM

Melbolt, thank you for the reply. I've been constructing a loop in my free time, but i've been put on another project for a couple days so it might be a bit before I can respond. I'll be back, but for now, I've got to ask other questions. Dag nabit.


All times are GMT -5. The time now is 2:12 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC