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 4606804
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:36:57+00:00 2026-05-22T00:36:57+00:00

What I want is to have a ComboBox which, upon SelectedIndexChanged , changes a

  • 0

What I want is to have a ComboBox which, upon SelectedIndexChanged, changes a Timer.Interval. My code basically looks like this:

public Form1()
{
    InitializeComponent();
    Timer AutoRefresh = new Timer();
    AutoRefresh.Tick += new EventHandler(AutoRefresh_Tick);
    var RefreshIntervals = new[] { "4 hours", "2 hours", "1 hour", "15 minutes", "10 seconds" };
    comboBox1.DataSource = RefreshIntervals;
    comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged);
}

void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (AutoRefresh.Enabled == true)
        AutoRefresh.Enabled = false;
    if (comboBox1.SelectedText == "4 hours")
        AutoRefresh.Interval = 14400000;
    else if (comboBox1.SelectedText == "2 hours")
        AutoRefresh.Interval = 7200000;
    else if (comboBox1.SelectedText == "1 hour")
        AutoRefresh.Interval = 3600000;
    else if (comboBox1.SelectedText == "15 minutes")
        AutoRefresh.Interval = 900000;
    else if (comboBox1.SelectedText == "10 seconds")
        AutoRefresh.Interval = 10000;
    AutoRefresh.Enabled = true;
}

Now, obviously this doesn’t work because comboBox1_SelectedIndexChanged() doesn’t have a reference to a Timer variable.

How can I modify my code to pass AutoRefresh to comboBox1_SelectedIndexChanged()?

Probably a good time to point out that I’m still a novice with C#. Please be kind.

  • 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-22T00:36:58+00:00Added an answer on May 22, 2026 at 12:36 am

    The SqlDependency class may work well for you, based on the comment you made:

    … The program … queries a SQL DB which fills a DataTable for display. I want to use this comboBox and the Timer to automatically refresh the DataTable …

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

Sidebar

Related Questions

I have a table in SQL Server which looks like this: ID Code Name
This is what I'm talking about: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx basically I want to have a drop
In .net, I have an inherited control: public CustomComboBox : ComboBox I simply want
I have multiple textboxes which I want them to perform the same thing upon
I have an ExtJS combobox, which is a required field, but I don't want
I would like to have a ComboBox control on a form which will be
I have a ComboBox which I cannot bind directly to (due to this bug
I want to have a select-only ComboBox that provides a list of items for
I have a System.Windows.Forms.ComboBox on a form and I want to capture the event
I have a listview with a DataTemplate that has a ComboBox. I want the

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.