PDA

Click to See Complete Forum and Search --> : Buttons.visible?


flog3941
Nov 13th, 2002, 04:33 PM
Im using a streamreader and a streamwriter, what im trying to do is record wether a button is visible at the time the stream writer writes. I have a form that the buttons are visible sometimes then after certan actions they are not and I need to keep track of that.

MrPolite
Nov 13th, 2002, 05:03 PM
well why dont you just check for the Visible property of your button?

flog3941
Nov 13th, 2002, 05:11 PM
This is what i have, the only thing is the its not recorcing the .visible part!



Dim st1 As New System.IO.StreamReader(New System.IO.FileStream("c:\Documents and Settings\Owner\My Documents\" & fname, IO.FileMode.OpenOrCreate))
form2.TextBox32.Text = st1.ReadLine
form2.signinfri.Visible = st1.Read
form2.signoutfri.Visible = st1.Read


Dim sw1 As New System.IO.StreamWriter(New System.IO.FileStream("c:\Documents and Settings\Owner\My Documents\" & fname, IO.FileMode.Truncate))
sw1.WriteLine(TextBox32.Text)
sw1.Write(signinfri.Visible)
sw1.Write(signoutfri.Visible)

Lethal
Nov 13th, 2002, 06:51 PM
If I was you, I would take advantage of the BinaryReader/Writer classes. These classes can read and write data from a stream directly into typed variables.


private void button1_Click(object sender, System.EventArgs e)
{
FileStream outStream = File.Create(@"c:\settings.dat");
BinaryWriter bwSettings = new BinaryWriter(outStream);

// save button visibility state
bwSettings.Write((bool)this.button1.Visible);
bwSettings.Flush();
bwSettings.Close();
FileStream inStream = File.OpenRead(@"c:\settings.dat");
BinaryReader brSettings = new BinaryReader(inStream);
bool visiblity = brSettings.ReadBoolean();
MessageBox.Show(visiblity.ToString());
}

MrPolite
Nov 13th, 2002, 08:31 PM
just try .visible.tostring instead of .visible