Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
Questionhow to ingnore some characters in serach by Regular Expressions Pin
hdv21225-May-07 3:46
hdv21225-May-07 3:46 
AnswerRe: how to ingnore some characters in serach by Regular Expressions Pin
Judah Gabriel Himango25-May-07 4:44
sponsorJudah Gabriel Himango25-May-07 4:44 
Questionproblem in inserting data Pin
Mujz.........25-May-07 3:46
Mujz.........25-May-07 3:46 
AnswerRe: problem in inserting data Pin
Judah Gabriel Himango25-May-07 4:14
sponsorJudah Gabriel Himango25-May-07 4:14 
GeneralRe: problem in inserting data Pin
Mujz.........26-May-07 8:48
Mujz.........26-May-07 8:48 
AnswerRe: problem in inserting data Pin
Dave Herren25-May-07 4:20
Dave Herren25-May-07 4:20 
GeneralRe: problem in inserting data Pin
Mujz.........27-May-07 22:08
Mujz.........27-May-07 22:08 
QuestionSerialization problem Pin
Mark F.25-May-07 3:38
Mark F.25-May-07 3:38 
I want to serialize program settings to a binary file. The problem is that the settings are written to a binary file but I cannot retrieve them into a propertygrid control. Here is the code.
<code>// ProgramSettings class
namespace OpsTest
{
    [Serializable()]
    public class ProgramSettings
    {
        private Font    _editorFont;
        private Color   _editorTextColor;

        [Category("Editor Settings"),
        Description("The font used by the editor.")]
        public Font EditorFont
        {
            get { return _editorFont; }
            set { _editorFont = value; }
        }

        [Category("Editor Settings"),
        Description("The text color used by the editor.")]
        public Color EditorTextColor
        {
            get { return _editorTextColor; }
            set { _editorTextColor = value; }
        }
    }
}

// OptionsDialog class
    public partial class OptionsDialog : Form
    {
        ProgramSettings mySettings = new ProgramSettings();

        public OptionsDialog()
        {
            InitializeComponent();
        }

        private void OptionsDialog_Load(object sender, EventArgs e)
        {
            optionsPropertyGrid.SelectedObject = mySettings;
            SerializeLoad();
        }

        public void SerializeLoad()
        {
            string sFilename = Path.GetDirectoryName(Application.ExecutablePath) + @"\settings.dat";
            if (File.Exists(sFilename))
            {
                Stream inStream = File.Open(sFilename, FileMode.Open);
                BinaryFormatter bf = new BinaryFormatter();
                mySettings = (ProgramSettings)bf.Deserialize(inStream);
                inStream.Close();
            }
        }

        public void SerializeStore()
        {
            string sFilename = Path.GetDirectoryName(Application.ExecutablePath) + @"\settings.dat";
            Stream outStream = File.Open(sFilename, FileMode.Create);
            BinaryFormatter bf = new BinaryFormatter();
            bf.Serialize(outStream, mySettings);
            outStream.Close();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            SerializeStore();
            this.Close();
        }
</code>
The categories are there but no values appear in the propertygrid!

Thanks,
Mark



-- modified at 9:50 Friday 25th May, 2007
AnswerRe: Serialization problem Pin
JoeSharp25-May-07 4:05
JoeSharp25-May-07 4:05 
AnswerRe: Serialization problem Pin
Manoj Kumar Rai25-May-07 4:36
professionalManoj Kumar Rai25-May-07 4:36 
GeneralRe: Serialization problem Pin
Mark F.25-May-07 5:01
Mark F.25-May-07 5:01 
QuestionDesigning MenuStrip in derived form Pin
Evil_Giraffe25-May-07 3:27
Evil_Giraffe25-May-07 3:27 
QuestionHow to Identify mail Language? Pin
ArunkumarSundaravelu25-May-07 2:44
ArunkumarSundaravelu25-May-07 2:44 
AnswerRe: How to Identify mail Language? Pin
Paddy Boyd25-May-07 2:59
Paddy Boyd25-May-07 2:59 
GeneralRe: How to Identify mail Language? Pin
ArunkumarSundaravelu25-May-07 3:04
ArunkumarSundaravelu25-May-07 3:04 
AnswerRe: How to Identify mail Language? Pin
Muammar©25-May-07 7:34
Muammar©25-May-07 7:34 
GeneralRe: How to Identify mail Language? Pin
ArunkumarSundaravelu28-May-07 0:09
ArunkumarSundaravelu28-May-07 0:09 
Questionrerieving of logon hours of a user in active directory Pin
Mickky25-May-07 2:29
Mickky25-May-07 2:29 
Questioncontrolling wpf window with normal c# form? Pin
Mir_As25-May-07 2:01
Mir_As25-May-07 2:01 
AnswerRe: controlling wpf window with normal c# form? Pin
teejayem25-May-07 2:16
teejayem25-May-07 2:16 
QuestionWriting a plug In Pin
IrfanHaleem25-May-07 1:46
IrfanHaleem25-May-07 1:46 
AnswerRe: Writing a plug In Pin
JoeSharp25-May-07 2:01
JoeSharp25-May-07 2:01 
GeneralRe: Writing a plug In Pin
Tarakeshwar Reddy25-May-07 3:11
professionalTarakeshwar Reddy25-May-07 3:11 
QuestionBinding TreeView Control to an Arraylist Pin
KKrista25-May-07 1:45
KKrista25-May-07 1:45 
AnswerRe: Binding TreeView Control to an Arraylist Pin
Manoj Kumar Rai25-May-07 2:03
professionalManoj Kumar Rai25-May-07 2:03 

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.