Click here to Skip to main content
15,894,539 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to Unhide the Hidden form Pin
DaveyM697-Sep-10 2:04
professionalDaveyM697-Sep-10 2:04 
GeneralRe: How to Unhide the Hidden form Pin
OriginalGriff7-Sep-10 2:18
mveOriginalGriff7-Sep-10 2:18 
AnswerRe: How to Unhide the Hidden form Pin
DaveyM697-Sep-10 2:01
professionalDaveyM697-Sep-10 2:01 
GeneralRe: How to Unhide the Hidden form Pin
Hum Dum8-Sep-10 0:25
Hum Dum8-Sep-10 0:25 
GeneralRe: How to Unhide the Hidden form Pin
DaveyM698-Sep-10 1:53
professionalDaveyM698-Sep-10 1:53 
GeneralRe: How to Unhide the Hidden form Pin
DaveyM698-Sep-10 1:57
professionalDaveyM698-Sep-10 1:57 
AnswerRe: How to Unhide the Hidden form Pin
Luc Pattyn7-Sep-10 2:32
sitebuilderLuc Pattyn7-Sep-10 2:32 
QuestionSave/Load Class Pin
_Q12_6-Sep-10 19:05
_Q12_6-Sep-10 19:05 
I finally made it working!!! I made a test here actually and i made it work. I can save and load from a text file...yeeey.
How can I made it more compact? I want to transform it into a stand alone Class that I can call it from anywhere in any situation. Any suggestions?
Thanks
Here is the code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SaveLoadNamespace;
using WarningsNamespace;
using System.Text.RegularExpressions;

namespace test7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        SaveLoadClass slc = new SaveLoadClass();
        WarningsClass wc = new WarningsClass();


        string tampon;
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                tampon = "checkBox = true" + "\r\n";
            }
            else
            {
                tampon = "checkBox = false" + "\r\n";
            }

            tampon += "numericUpDown = " + numericUpDown1.Value.ToString() + "\r\n"; ;
            tampon += "comboBox = " + comboBox1.Text + "\r\n"; ;

            slc.file_SaveFile(tampon); label2.Text = wc.w2;

        }

        string buffer, s = ""; int i, j = 0;
        private void buttonLoad_Click(object sender, EventArgs e)
        {
            //STRING MANIPULATION !!!
            slc.file_LoadFile(); label1.Text = buffer = slc.textToLoadInto; label3.Text = wc.w5;

            #region <_____ NumericUpDown _____>
            //NumericUpDown
            if (buffer.Contains("numericUpDown"))//if that,then should goto there
            {
                i = buffer.IndexOf("numericUpDown");
                s = buffer.Remove(0, i); //remove the Begining of string
                if (s.Contains("\r\n"))  //folowing operations remove the Ending part of the string
                {
                    i = s.IndexOf("\r\n");
                    j = s.Length - i;
                    s = s.Remove(i, j);
                }
                if (s.Contains("="))
                {
                    i = s.IndexOf("=") + 1;
                    s = s.Remove(0, i).Trim();
                }

                i = int.Parse(s);
                numericUpDown1.Value = i;
            }
            #endregion >NumericUpDown-END<

            #region <_____ checkBox _____>
            //checkBox
            if (buffer.Contains("checkBox"))//if that,then should goto there
            {
                i = buffer.IndexOf("checkBox");
                s = buffer.Remove(0, i); //remove the Begining of string
                if (s.Contains("\r\n"))  //folowing operations remove the Ending part of the string
                {
                    i = s.IndexOf("\r\n");
                    j = s.Length - i;
                    s = s.Remove(i, j);
                }
                if (s.Contains("="))
                {
                    i = s.IndexOf("=") + 1;
                    s = s.Remove(0, i).Trim(); 
                }

                if (s.Contains("true"))//s.Contains here is for: in case of whitespaces
                {
                    checkBox1.Checked = true;
                }
                if (s.Contains("false"))
                {
                    checkBox1.Checked = false;
                }
            }
            #endregion >checkBox-END<

            #region <_____ comboBox _____>
            //comboBox
            if (buffer.Contains("comboBox"))//if that,then should goto there
            {
                i = buffer.IndexOf("comboBox");
                s = buffer.Remove(0, i); //remove the Begining of string
                if (s.Contains("\r\n"))  //folowing operations remove the Ending part of the string
                {
                    i = s.IndexOf("\r\n");
                    j = s.Length - i;
                    s = s.Remove(i, j);
                }
                if (s.Contains("="))
                {
                    i = s.IndexOf("=") + 1;
                    s = s.Remove(0, i).Trim();
                }

                comboBox1.Text = s;
            }
            #endregion >comboBox-END<


        }
    }
}



The output is like this:
checkBox = true
numericUpDown = 24
comboBox = red
AnswerRe: Save/Load Class Pin
SeMartens6-Sep-10 20:41
SeMartens6-Sep-10 20:41 
GeneralRe: Save/Load Class Pin
_Q12_6-Sep-10 23:28
_Q12_6-Sep-10 23:28 
GeneralRe: Save/Load Class Pin
_Q12_7-Sep-10 8:10
_Q12_7-Sep-10 8:10 
QuestionRe: Save/Load Class Pin
Ravi Bhavnani7-Sep-10 10:29
professionalRavi Bhavnani7-Sep-10 10:29 
AnswerRe: Save/Load Class Pin
_Q12_7-Sep-10 12:34
_Q12_7-Sep-10 12:34 
GeneralRe: Save/Load Class Pin
Ravi Bhavnani8-Sep-10 4:42
professionalRavi Bhavnani8-Sep-10 4:42 
AnswerRe: Save/Load Class Pin
c0ax_lx8-Sep-10 4:57
c0ax_lx8-Sep-10 4:57 
AnswerRe: Save/Load Class Pin
_Q12_8-Sep-10 20:04
_Q12_8-Sep-10 20:04 
AnswerRe: Save/Load Class Pin
_Q12_10-Sep-10 19:26
_Q12_10-Sep-10 19:26 
QuestionProblem installing sql server 2005 express through code. Pin
MayukhSen6-Sep-10 18:42
MayukhSen6-Sep-10 18:42 
QuestionreportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) [modified] Pin
amitcoder836-Sep-10 18:00
amitcoder836-Sep-10 18:00 
AnswerRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
Richard MacCutchan6-Sep-10 21:37
mveRichard MacCutchan6-Sep-10 21:37 
GeneralRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
amitcoder836-Sep-10 23:19
amitcoder836-Sep-10 23:19 
GeneralRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
Richard MacCutchan7-Sep-10 1:09
mveRichard MacCutchan7-Sep-10 1:09 
AnswerRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
phil.o6-Sep-10 23:28
professionalphil.o6-Sep-10 23:28 
AnswerRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
amitcoder836-Sep-10 23:39
amitcoder836-Sep-10 23:39 
GeneralRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
Rhys Gravell6-Sep-10 23:43
professionalRhys Gravell6-Sep-10 23:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.