|
I have tried out this code. This ignores the button altogether and seems to work just fine:
using System;
using System.IO;
using System.Xml.Serialization;
using System.Windows.Forms;
namespace SerialTest
{
public class Group
{
[XmlIgnoreAttribute]
public System.Windows.Forms.Button myButton;
public string GroupName;
public string Comment;
public void SerializeObject(string filename)
{
XmlSerializer xSer = new XmlSerializer(typeof(Group));
TextWriter writer = new StreamWriter(filename);
xSer.Serialize(writer, this);
writer.Close();
}
}
}
To run this the example I used was a form with a button and the following code on the OnClick event:
Group a = new Group();
a.Comment="A sample comment";
a.GroupName="A sample group name";
a.myButton = this.button1;
a.SerializeObject("c:\\test.xml");
That worked.
- Eitsop
What we do not understand we do not possess. - Goethe.
|
|
|
|
|
Yeah this works I know.
I think(hope i did) i mentioned it that mybutton is an object of
<br />
class MyButton:System.Windows.Forms.Button <br />
What you have created is a "standard" button and i have a custom button that inherits System.Windows.Forms.Button.
So i wonder if there is any problems with inherited classes using XmlSerializer ?
|
|
|
|
|
Eitsop wrote: When you say XmlIgnore, do you mean that you have applied the XmlIgnoreAttribute? i.e.
[XmlIgnoreAttribute]
public string Comment;
Indeed you are right
rakhi2020[.]
|
|
|
|
|
Well, I do not immediately see any problem but why is that button declared as public anyway?
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Is there any way of eliminating the need of having the Dlls my program is dependent of, in the same folder the executable is? I mean, I have a program that uses some Dlls, but I don't like the need of having to copy them along with the program, if I need to move it. Isn't there any way of embedding the Dlls as a resource or something like that?
Thanks in advice (and sorry if my English is too bad.. )
|
|
|
|
|
Hi
You can register your dlls in Global Assembly Cache (GAC)But if you want to deploy your program you should have a setup program that register your assmeblies in GAC.
Regards
Nima H
|
|
|
|
|
I have created a cliecnt server application using .Net Remoting.
How can i check whether a connection is established or not.
presently, i am checking it by catching the ServerException thrown whenever i tries to access my remotable class. Its a time consuming process.
is there any API through which i can check this like we have in socket programmming.
Thanks in advance
Praveen Raghuvanshi
Software Engineer
|
|
|
|
|
I need a simple example of a Stack in C#.
|
|
|
|
|
|
Because he knows that someone will "be nice" and answer his homework here.
|
|
|
|
|
Stack<int> stack = new Stack<int>();
stack.Push(1);
stack.Push(2);
stack.Push(3);
Console.WriteLine(stack.Pop());
Console.WriteLine(stack.Pop());
Console.WriteLine(stack.Pop());
|
|
|
|
|
.NET already has a Stack class in the System.Collections namespace.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
I have added a web reference to the web service from the client project.
The webservice is called ItemsWebService
The webservice has two .asmx files
i.e. orders.asmx and employees.asmx
from the client I would like to call the ItemsWebService. So that the relevant forms on the client calls the appropriate .asmx file.
i.e. the orders form in client calls ItemsWebService.Orders
and the employees form on the client calls ItemsWebService.Employees
At present when I add a web refernce to this webservice from the client I get the two names i.e. orders and employees. I think I should get just the itemsWebService.
Am I right?
Thanks
|
|
|
|
|
The webservice creates a reference to each .asmx file within it.
You could just create 1 file called MyService.asmx (for example), then each form could reference ItemsWebservice.MyService.whatever rather than distinguishing between the two files.
fmardani wrote: At present when I add a web refernce to this webservice from the client I get the two names i.e. orders and employees.
This is what you should expect to happen.
ChrisB
|
|
|
|
|
Hi all,
I want to show a form in another form not using MdiParent property or in another control and get events(i.e activated, enter).
I can add a form in another form or control setting TopLevel property to false but sub form's events (activated, enter) never works.
A sample for this situation is Microsoft Access. As you know that access is a MDI application. In Access in query design MDI child window the query tables shown as a form. (i.e MDIParent Form --> Query Design MDIChild Form --> query table form(s) ).
I want to develop similar design and I never get sub form's events
Any suggestion?
Thanks in advance...
|
|
|
|
|
Couldn't you define your own events in subform to which mainform subscribes too? Then call them from the subforms eventhandlers for instance?
-Larantz-
|
|
|
|
|
Hi Larantz,
I have two sub forms that in MDIChild form and i want to listen the selected change (or activate) of sub forms.
|
|
|
|
|
Maybe you could do something along the lines of this:
public class ParentForm : Form
{
private SubForm sub1;
private SubForm sub2;
public ParentForm()
{
InitializeSubForms();
}
private void InitializeSubForms()
{
sub1 = new SubForm();
sub1.OnSelectionChanged += new SubForm.SelectionChanged(sub1_OnSelectionChanged);
sub2 = new SubForm();
sub2.OnSelectionChanged += new SubForm.SelectionChanged(sub2_OnSelectionChanged);
}
void sub1_OnSelectionChanged(object sender, EventArgs e)
{
}
void sub2_OnSelectionChanged(object sender, EventArgs e)
{
}
}
public class SubForm : Form
{
private DataGridView dgv;
public delegate void SelectionChanged(object sender, EventArgs e);
public event SelectionChanged OnSelectionChanged;
public SubForm()
{
dgv = new DataGridView();
dgv.SelectionChanged += new EventHandler(dgv_SelectionChanged);
}
void dgv_SelectionChanged(object sender, EventArgs e)
{
if (OnSelectionChanged != null)
OnSelectionChanged(sender, e);
}
}
Best regards!
-Larantz-
|
|
|
|
|
hi friends
are there anybody knows how can i connect a server with username and password with c#? i want to make response with my functions which i take from that server's whdl...
|
|
|
|
|
Hello Experts...
I want to detect the Machine shutdown event...
HOW CAN I DO THAT?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Have a look at the SystemEvents.SessionEnding event.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks....
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
private void AddEventHandler()<br />
{<br />
Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler(PowerModeChangedSub);<br />
}<br />
<br />
private void PowerModeChangedSub(object sender, Microsoft.Win32.PowerModeChangedEventArgs e)<br />
{<br />
switch (e.Mode)<br />
{<br />
case Microsoft.Win32.PowerModes.Resume:<br />
break;<br />
case Microsoft.Win32.PowerModes.StatusChange:<br />
break;<br />
case Microsoft.Win32.PowerModes.Suspend:<br />
break;<br />
default:<br />
break;<br />
}<br />
}
.:: Something is Wrong ::.
|
|
|
|
|
how can we restrict the value entered in the flexgrid,(ketpress event is not working).They provided one keypressedit event,but its also not working.
My small attempt...
|
|
|
|
|
I've been looking around for a while, and i've found the Marshal.Copy() function, but that's not really what i'm looking for.
Is there any way to actualy copy a managed object in memory, as opposed to instantiating a new one? I don't really want to enter the realms of unmanaged copying, unless i can drop the unmanaged reference at the end of the copy function.
Any thoughts?
cheers
Tris
|
|
|
|