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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:17:00+00:00 2026-06-11T13:17:00+00:00

I want to be able in Form1 constructor for example to type: Options_DB.Save Something

  • 0

I want to be able in Form1 constructor for example to type: Options_DB.Save
Something like that or Options_DB.Save(true) or (false)
So if its false the class will not take effect onl all the settings i did in Form1 according to Options_DB and if its true it will take effect and do all the things in the class Options_DB.

This is the class Options_DB:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DannyGeneral;
using System.IO;
using System.Windows.Forms;

namespace GatherLinks
{
    static class OptionsDB
    {
        static string changeWebsite;
        static bool downloadImages;
        static bool localOnly;
        static decimal num1;
        static string num1_numricupdown;
        static string path_exe;
        static string path_settings;
        static string settings_file;
        static string settings_dir;
        static OptionsFile setting_file;

        static OptionsDB()
        {
            path_exe = Path.GetDirectoryName(Application.LocalUserAppDataPath);

            path_settings = Path.GetDirectoryName(Application.LocalUserAppDataPath);
            settings_file = "\\settings.txt";
            settings_dir = path_settings + @"\settings";
            setting_file = new OptionsFile(settings_dir + settings_file);

            // ---- L O A D I N G   A L L   K E Y S ---- \\

            changeWebsite = setting_file.GetKey("changeWebSite");
        }
        // ---- FUNCTIONS GET AND SET ---- \\

        public static string get_changedWebSite()
        {
            return changeWebsite;
        }

        public static void set_changeWebSite(string website)
        {
            changeWebsite = website;
            setting_file.SetKey("changeWebSite", changeWebsite);

        }
    }
}

And im using in it in Form1 for example like this:

In the Form1 constructor:

mainUrl =  OptionsDB.get_changedWebSite();

And in the button2 click event:

private void button2_Click(object sender, EventArgs e)
        {
            cl = new ChangeLink();
            cl.StartPosition = FormStartPosition.CenterParent;
            DialogResult dr = cl.ShowDialog(this);
            if (dr == DialogResult.Cancel)
            {
                cl.Close();
            }
            else if (dr == DialogResult.OK)
            {    
                    label4.Text = cl.getText();
                    mainUrl = cl.getText();
                    OptionsDB.set_changeWebSite(cl.getText());
                    cl.Close();
            } 


        }

Now in the Form1 constructor before im doing the Options_DB.get…
I want to add a property of the Options_DB or something that will tell me if to do the class the new class or not. This class im using a lot of time already to save on a text file all the options like checkBoxes and things so when i run the program it will remember the settings i changed.

Now i want a property that will tell the program of to save any changes i did or not to save them.

  • 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-06-11T13:17:02+00:00Added an answer on June 11, 2026 at 1:17 pm

    This is the best I can do based on your question. It is hard to read/understand your question

    private static bool isActive; // The new property; put it with the rest of the statics
    public static string get_changedWebSite()
    {
        return changeWebsite;
    }
    
    public static void set_changeWebSite(string website)
    {
        if (isActive) // Check if it is active or not
        {
            changeWebsite = website;
            setting_file.SetKey("changeWebSite", changeWebsite);
        }
    }
    
    public bool IsActive // Get and set
    { 
      get
      {
         return isActive;
      } 
      set
      {
          isActive = value;
      } 
    }
    

    In Form1 just write OptionsDB.IsActive = false; to turn off. OptionsDB.IsActive = true; to turn on. Possibly setting the initial value in the constuctur (static OptionsDB()).

    Finally, you can really just change your get and set method to use Accessors. Like the Get and Set I used. –Side advise; just because you can

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

Sidebar

Related Questions

I have a form that accepts image file, i want to be able to
I want that the user shouldn't be able to resize the window form. I
I have a table of users that I want other users to be able
I have a container class (called Atom) that I want to store objects of
I want to be able to transfer values from one DataGridView in Form1 to
I want: To be able to open a form, select an item from a
I want to be able to do the following actions with a form submit
I want to be able to click a button and open a new form
I want to be able to pass fields into the edit form when a
I am going to use forms authentication but I want to be able to

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.