|
-
March 8th, 2005, 05:57 PM
#1
Changable preferences
I have a Dialog which houses all my preferences that can be changed.
On save it saves all the information to an XML.
I am having trouble figuring out a good way to do this:
There is to be a setting which can have multiple entires.
So for example say I am trying to set the levels of users.
Level1 - Admin
Level2 - Asst Admin
Level3 - Mgmt
Level4 - user
if the user goes into the preferences these 4 will be displayed to them. But say they want more levels they should be able to add more in, or if they want to remove, they can, or rename.
The way I was planning on implementing this is:
it would show 'X' textbox's to the user with the levels
if they press the 'Add button' a new textbox with a blank entry would be created under the previous and they can enter in and save.
next to the textbox's would be a checkbox, if they check the box and press delete the textboxs with a checkbox with a check are deleted.
Rename would be simply done by changing the text in the textbox.
Upon exiting the dialog it resaves the settings.
Can anyone think of a better way to approach this?
Last edited by Ctwizzy; March 16th, 2005 at 01:09 PM.
Will Rate Posts for help!
-
March 16th, 2005, 01:09 PM
#2
Re: Advise on best way to do this.
Maybe an ArrayList of textbox's ugh, this seems like a weird way of doing this.
Last edited by Ctwizzy; March 16th, 2005 at 01:32 PM.
Will Rate Posts for help!
-
March 16th, 2005, 02:51 PM
#3
Re: Advise on best way to do this.
This looks ugly to me. Change the number of controls dinamically... What someone creates 10 or 20 user levels? It's probably unlikely, bu what if? Will you have space for all?
I would suggest a list box, or perhaps a checked list box. You can add or remove any items to/from it without woring for problems with form space.
Just my 2 cents.
-
March 16th, 2005, 04:11 PM
#4
Re: Advise on best way to do this.
Ok so a list/combo is better.
So let them enter stuff in and then just go thru the collection parsing out the differences?
Will Rate Posts for help!
-
March 16th, 2005, 07:16 PM
#5
Re: Advise on best way to do this.
Ok so like this?
Code:
//reading
//Determine # of positions
Int32 positions = config.Read("numPositions");
for (Int32 index = 1; index <= positions; index++)
{
//positions would be listed as position1, position2, position3, position4 etc
this.lstBoxPositions.Items.Add(config.Read("position" + index)); }
then for writing
Code:
//this doesnt work as listBox has no length property or no easy way of //finding out how many entries are in it
config.Write("numPositions", this.lstBoxPositions.length);
for (Int32 index = 0; index <= this.lstBoxPositions.length; index++)
{
config.Write("position" + (index + 1), this.lstBoxPositions.Items[index].ToString());
}
Only problem with this I can see is that if they had 10 and erased 5, 5 would still be in the xml file, just wouldnt be used. I guess I could just
Code:
for (Int32 index = lstBoxPositions.Length(); index < oldLength; index++)
{
config.Write("position" + (index + 1), "");
}
this way the lines would still be there but the text would be gone. Would have to figure out a way to erase the lines in the xml files otherwise.
if anyone can think of a cleaner way to do this, let me know thanks.
Will Rate Posts for help!
-
March 16th, 2005, 07:22 PM
#6
Re: Advise on best way to do this.
ok figured out num of items in listbox.
this.lstBoxPositions.Items.Count
Will Rate Posts for help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|