Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7036323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:24:38+00:00 2026-05-28T01:24:38+00:00

I’m working on storing last used settings and then when program starts retrieve them

  • 0

I’m working on storing last used settings and then when program starts retrieve them back. Everything works fine but I just don’t know how to deal with ListBox items.

To point out one thing is that I’m already using one delimiter to store my settings. I’m getting quite confused when dealing with this problem.

This is how I store my settings:

private void btnStart_Click(object sender, EventArgs e)
{
    int interval = 0;
    int plusMinus = 0;
    int pause = 0;
    int delay = 0;
    int randomLine = 0;

    if (cbPause.Checked == true) pause = 1;
    if (cbDelay.Checked == true) delay = 1;
    if (cbRandomLine.Checked == true) randomLine = 1;
    interval = int.Parse(nudInterval.Value.ToString());
    plusMinus = int.Parse(nudPlusMinus.Value.ToString());

    lastUsed.Text = 
        interval + splitString + 
        plusMinus + splitString + 
        pause + splitString + 
        delay + splitString + 
        randomLine;

    if (nudPlusMinus.Value == 0)
    {
        tmrInterval.Interval = int.Parse(nudInterval.Value.ToString());
    }
    else
    {
        Random random = new Random();
        tmrInterval.Interval = random.Next(int.Parse(nudInterval.Value.ToString()) - int.Parse(nudPlusMinus.Value.ToString()), int.Parse(nudInterval.Value.ToString()) + int.Parse(nudPlusMinus.Value.ToString()));
    }

    WhenStarted();

    tmrInterval.Start();
}

This is how I retrieve them at the program start up:

public AutoTyper()
{
    InitializeComponent();

    tmrInterval.Tick += new EventHandler(Interval);
    tmrDelay.Tick += new EventHandler(Delay);
    tmrSpace.Tick += new EventHandler(Space);

    lbMessage.SelectedIndexChanged += new EventHandler(lbMessage_SelectedIndexChanged);
    txtMessage.TextChanged += new EventHandler(txtMessage_TextChanged);

    SetInterval();

    if (!lastUsed.EmptyFile())
    {
        string[] allSettings = lastUsed.Text.Split(splitChar, StringSplitOptions.None);
        int settingCount = 0;
        int settingNumber = 0;

        foreach (string setting in allSettings) settingNumber++;

        if (settingNumber == 5)
        {
            foreach (string setting in allSettings)
            {
                settingCount++;

                if (settingCount == 1) nudInterval.Value = int.Parse(setting);
                else if (settingCount == 2) nudPlusMinus.Value = int.Parse(setting);
                else if (settingCount == 3) { if (setting == "1") cbPause.Checked = true; }
                else if (settingCount == 4) { if (setting == "1") cbDelay.Checked = true; }
                else if (settingCount == 5) { if (setting == "1") cbRandomLine.Checked = true; }
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:24:38+00:00Added an answer on May 28, 2026 at 1:24 am

    Just retrieve/set SelectedIndex after adding all values (unless that happens at design time already).

    But in general, I’d rewrite that settings handling. You should store your settings using keys and values. Otherwise you’ll run into tons issue if you ever want to add, remove or change the order of some settings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.