|
If you vant to do it read only in the chech_canage event handler, set it's default value, eg.: if you want it to readonly and checked than in the handler :
if(!checked) checked=true;
I know it's disgusting, but somtimes disgusting thinks is the best way. Like Assembly it's disgusting and powerful
|
|
|
|
|
I am trying to make a form in outlook that I can manipulate to add controls to. I see that each item type is strongly typed and cannot see a generic class that I could inherit from as such. I thought that the OlItemType.olNoteItem would be a simple type and would like to be able to manipulate the form just like it was a windows form. Can anyone point me in the right direction?
I can create this note by doing this...
NoteItem objNoteItem = (NoteItem)applicationObject.CreateItem(OlItemType.olNoteItem);
Now I would like to change the interface of objNoteItem and place buttons and text fields and listen for events.
|
|
|
|
|
namespace NeuralNetwork
{
public class NeuralNetwork
{
public void SaveXML(StreamWriter SW)
{
SW.Write("<Neural Network>");
}
}
}
another file:
namespace NeuralNetwork
{
class Program
{
static void Main(string[] args)
{
NeuralNetwork nn = new NeuralNetwork(2);
nn.SaveXML(System.IO.File.CreateText("test.xml"));
}
}
}
Why wont this work.
I don't get any error but it doesn't write to the file.
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
|
Why does it write zeros?
How could I make it write something?
And I have flushed and closed the file but I forget to write it in the thread.
The real code is huge.
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
Niklas Ulvinge wrote:
Why does it write zeros?
I didn't say it writes zeros. I said it writes "zero bytes" - zero is a count of the number of bytes written. i.e. It writes nothing at all. It is a non-operation.
Niklas Ulvinge wrote:
How could I make it write something?
Supply some actual text to the Write() method.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
OK, now I get it...
This is what I got now:
public void SaveXML(string path)
{
StreamWriter SW = new StreamWriter(path, false);
SW.Write("<neural network="">");
//...
SW.Flush();
SW.Close();
}
It doesn't work.
The file is empty.
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
<small><b>Niklas Ulvinge wrote:</b></small>
<i>SW.Write("");</i>
This writes NOTHING. Or is there XML in here that is being stripped because you didn't check 'Do not treat <'s as HTML tags' ?
There's an XMLStreamWriter, I believe.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yes, that's why it didn't show up.
It write's xml. And that's the point.
The whole func:
public void SaveXML(string path)
{
StreamWriter SW = new StreamWriter(path, false);
SW.Write("<Neural Network>");
for (int l = 0; l < Layers.Length;l++ )
{
SW.Write(" <Layer>");
for (int n = 0; n < Layers[l].neurons.Length; n++)
{
SW.Write(" <Neuron number=\"" + GetNumber(this[l][n]) + "\n>");
SW.Write(" <Output value=\"" + this[l][n].output + "\n/>");
SW.Write(" <Weights>");
for (int w = 0; w < this[l][n].weights.Count; w++)
SW.Write(" <weight value= \"" + this[l][n].weights[w] + "\"/>");
SW.Write(" </Weights>");
SW.Write(" <Dendrites>");
for (int d = 0; d < this[l][n].dendrites.Count; d++)
{
SW.Write(" <dendrite number = \"" +GetNumber(this[l][n].dendrites[d]) + "\"/>");
}
SW.Write(" </Dendrites>");
//this[l][n].weights;
SW.Write(" </Neuron>");
}
SW.Write(" </Layer>");
}
SW.Flush();
SW.Close();
}
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
OK - given that you posted Write("") twice, and Colin brought it to your attention, you'd understand our confusion..
Your code works fine here - I took out the bit that iterates through the nodes, ran it and ended up with a file that was populated with XML. I have VS.NET 2003.
Is there an exception block somewhere that could be throwing silently, and thus causing the code to never Flush ? Try a flush before the loop that iterates through the nodes and see what you get, then try a try/catch locally in this code to see what the error is, if any.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I looked at wrong file...
Thank you all.
|
|
|
|
|
Sorry - had some extra thoughts and edited the reply. Basically, if an exception is thrown while iterating through the nodes, and is caught without notification by the code that calls this function, you may end up with an empty file, as no flush will occur. Try a flush before the loop and if you get the first open node in the file, that's probably what is going on.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I don't have eny exception handling yet...
It works now, so I'm not doing anything with it
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
It started working ? Cool. Can't imagine what was wrong before then...
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I looked at the wrong file.
There was 2 files one in the place I thought it would be and another that was where the program thought it should be...
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
Niklas Ulvinge wrote:
The file is empty.
Based on the code that I see that is the result I would expect.
As I've said you need to write stuff to the file. For example:
SW.Write("Some text goes here");
If you leave nothing in between the quotation marks then nothing will get written to the file.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
He's writing XML and didn't tick the box to show XML in his posts.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Hey everybody!
I have a small question about the FileMode.Append .
as far as I understood using the FileMode.Append, the serialization method will look for the end of the file and will serialize from there, so I can add objects to the file without overwriting the old information.
so lets say I have 3 objects in a file, and I added another object.
so in total I have 4 objects.
just for the example I'll compare it to a listbox.
we had 4 strings added by the user, all being saved using FileMode.Append (one by one).
but what if I want to remove a specific string (an object, a specific "string name") from the file. lets say the 2nd string (or object) that I saved.
is there a way to do that? some other way of using Append ???
thanks alot!
|
|
|
|
|
If you really want to remove it from the file you will have to rewrite it completely. This could be done by first deserializing it and then serieliazing the lements you wish to remain into another file (or overwriting the existing one). If you somehoew store the positions of the objects in the file you could also copy parts of it without serialize mechnisms into a new file.
Surely this will slow down performance. Another idea would be to just the leave the file as it is but skip those values you dont need while deserializing. You would then just clean up the file every once in a while.
|
|
|
|
|
|
Just an idea, what if you have a collection of objects, and everytime serialize and deserialize the whole collection? That way, you could in code add, remove, or change the items, and serialization would be automatic.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hello,
I created an xml file and created a class matching that file using xsd.exe tool. Im inserting data from the file to an instance of the class using serialization:Instance=(casting)XmlSerializer.Deserialize(FileStream),
and Im saving changes to the xml file:
XmlSerializer.Serialize(FileStream,Instance).
My problem is that sometimes when storing data from the instance of the class to the file destroys the fomat of the xml file and the file can no longer load unless I change it back. The format is destroyed by adding xml tags that belong to the file but not in the right place. This happens when I use the folderBrowserDialog to change one of the parameters of the instance and only on specific chosen directory of the dialog.
|
|
|
|
|
hi folks,
i am looking for some ideas as how i could go about adding icons to a context menu ??? For my purpose, my context menu looks at a particular dir and appends all available files to the menu. Each file that gets appended to the context menu, the associate application icon also gets appended on the left handside of the filename. I know how to extract the file icons. But as how to append each of the icons to it's respective file in the context menu i have no idea about.
One idea I had was to use a delgate to invoke the OnDrawItem Event handler each time the context menu is invoked ? I havent attempted to do this yet. Now is this a possible solution or are there alternatives i dont know about ??
i would appreciate any feedback.
thanks
|
|
|
|
|
well i had received an email from an anonymous user at CP asking me if i had come up with a solution to my problem. Well yes and no is the response. No because i couldnt work out the delegate aspect of the solution. Yes because i saw another article in which the author used main menu and ownderdrawn method to append the icons.
The article is here :
http://www.csharphelp.com/archives/archive282.html
The article did provide me with an idea of how to tackle my problem. However, I have had other things to do so I havent had much time to try it out. If I have some time over the weekend or next week I will post back my solution.
so hope this helps.
cheers
|
|
|
|