|
What exactly do you think that a serialized event handler would represent?
What do you expect it to do when you deserialize an event handler?
|
|
|
|
|
Using Windows Form, you cannot directly serialize Buttons or TextBox and other controls, but in XAML you can do this. however if once I have created the button and attached a "click" event per say, then when serializing the button, the xaml serializer will produce and error because of that click event.
My main goal is able to create a user interface, attach event to different controls, and being able to saved (serialize) them to a file, and the same way the other way around.
I hope I was clear enough.
Yanick
|
|
|
|
|
How about writing a pre-processing method that reflects all controls, unregistering each event and saving it to a textfile? You could then generate a new assembly based on the list of events in your textfile that re-attaches the eventhandlers
I are Troll
|
|
|
|
|
Hi,
Thanks a lot for your input, by using your suggestion I guess I will have to use reflection. I was hoping not to, and maybe try another maybe simpler avenue to achieve the same result because I have not worked with reflections as of yet.
Regards
Yanick
|
|
|
|
|
Serval Soft wrote: Using Windows Form, you cannot directly serialize Buttons or TextBox and other controls, but in XAML you can do this
No.
The XAML contains a description which maps to a control. It doesn't contain the control itself.
http://blogs.msdn.com/b/mhendersblog/archive/2005/10/07/478284.aspx[^]
If you want some arbitrary event handler to do the same then you need to provide sufficient information to provide a description (not the event handler) so it can be mapped as well.
I would suspect that there might even be some fairly easy way to do that if one wrapped the event handler in a class and derived from the correct object. However depending on the layout I would suspect it would be easier and more correct to create your own controls which have event handlers and then do the appropriate work to map those controls into XAML.
|
|
|
|
|
Hi. Newest way to create a modern dictionary. For example, what bank is used or what is interface design?
Thanks!
|
|
|
|
|
I'm sorry, but that doesn't make any sense as a question. I am sure that English is not your native language, but please try to give more detail on what the problem is, so that we can help. It may be worth describing it is small words in your native language and then using Google Translate to get it into English.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Sorry - but what are you talking about?
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
Try here[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
you question is not clear. Please clarify.
|
|
|
|
|
do you mean, how to implement IDictionary ?
|
|
|
|
|
I want to update Some Value to Marked Number Value in MarkedNumber Column
I Want to know where's the error in this code
public void UpdateMessageToIncludeMarkedNumber()
{
#region Compare to Insert Marked Number With Matching Message into Table in Database.
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "update VopMessage_tbl set MarkedNumber=@MarkedNumber where Byte24=@Byte24 and Byte4=@Byte4";
cmd.Connection = con;
for (int t = 0; t < Set10bytesMessage.Count; t++)
{
MarkedNumber mNumber = (MarkedNumber)Set10bytesMessage[t];
for (int f = 0; f < Set30bytesMessage.Count; f++)
{
VopMessage vms = (VopMessage)Set30bytesMessage[f];
if (mNumber.Byte4 == vms.Byte24 & mNumber.Byte5 == vms.Byte4)
{
cmd.Parameters.AddWithValue("@Byte24", vms.Byte24);
cmd.Parameters.AddWithValue("@Byte4", vms.Byte4);
string All2BytesOfTwoMarkedNumber = mNumber.Byte4 + mNumber.Byte5;
cmd.Parameters.AddWithValue("@MarkedNumber", All2BytesOfTwoMarkedNumber);
}
else
{
}
}
}
con.Open();
cmd.ExecuteNonQuery();
con.Close();
#endregion
}
|
|
|
|
|
You are only processing the last item in in Set30bytesMessage for the last item in Set10bytesMessage , if at all???
You repeatedly add the parameters in the the loop, so each parameter is potentially added more than once. Without knowing exactly what you are doing it is hard to tell but I'd hazard a guess and say you need to do this:
- The you should add the parameters before the loop
- The values of the parameters should be set inside the loop
- The
ExecuteNonQuery should happen inside the loop for each item
Is that any help? Some clue about what is going wrong/ what you expect would be good!
|
|
|
|
|
Here's the Error
The variable name '@Byte24' has already been declared. Variable names must be unique within a query batch or stored procedure.
If I put : cmd.Parameters.AddWithValue("@Byte24", vms.Byte24);
cmd.Parameters.AddWithValue("@Byte4", vms.Byte4);
out side loop , from where can I get the value of vms.Byte24
|
|
|
|
|
See my previous reply, my guess was correct!
public void UpdateMessageToIncludeMarkedNumber()
{ SqlCommand cmd = new SqlCommand();
for (int t = 0; t < Set10bytesMessage.Count; t++)
{
MarkedNumber mNumber = (MarkedNumber)Set10bytesMessage[t];
for (int f = 0; f < Set30bytesMessage.Count; f++)
{
VopMessage vms = (VopMessage)Set30bytesMessage[f];
if (mNumber.Byte4 == vms.Byte24 & mNumber.Byte5 == vms.Byte4)
{
<big>
}
}
}
con.Open();
<big>
cmd.ExecuteNonQuery();
con.Close();
}
}
|
|
|
|
|
+5 on the original answer, but wouldn't clearing the Parameters collection more efficient? He'd be reusing them for the same task, which seems logical.
Just curious
I are Troll
|
|
|
|
|
Eddy Vluggen wrote: wouldn't clearing the Parameters collection more efficient?
After clearing the collection you would need to add the parameters again, creating more objects each time the loop runs. It is far more efficient to update the existing parameters.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: After clearing the collection you would need to add the parameters again, creating more objects each time the loop runs.
Yup, true. Thanks for the explanation
I are Troll
|
|
|
|
|
You Should Now that from this loop If the condition
if (mNumber.Byte4 == vms.Byte24 && mNumber.Byte5 == vms.Byte4)
not occur , no repeat will done and also you will should now that the condition will occur only one time.
|
|
|
|
|
The error you are getting indicates that Parameters are being added more that once so your loop is being executed multiple times.
Add the parameters when creating the SqlCommand
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "update VopMessage_tbl set MarkedNumber=@MarkedNumber where Byte24=@Byte24 and Byte4=@Byte4";
cmd.Connection = con;
cmd.Parameters.Add("@Byte24", ...);
cmd.Parameters.Add("@Byte4", ...);
cmd.Parameters.Add("@MarkedNumber", ...);
Then inside the loop update the values each time
cmd.Parameters["@Byte24"] = vms.Byte24;
cmd.Parameters["@Byte4"] = vms.Byte4;
string All2BytesOfTwoMarkedNumber = mNumber.Byte4 + mNumber.Byte5;
cmd.Parameters["@MarkedNumber"] = All2BytesOfTwoMarkedNumber;
cmd.ExecuteNonQuery();
You should also make use of the using statement
using(SqlCommand cmd = new SqlCommand("update VopMessage_tbl set MarkedNumber=@MarkedNumber where Byte24=@Byte24 and Byte4=@Byte4", conn)
{
}
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks very Much ...It Work Correctly.
|
|
|
|
|
What error message are you getting?
Jack of all trades ~ Master of none.
|
|
|
|
|
You could easily find the error if you just used the tools that come with Visual Studio - namely, the debugger.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Hi
I have discovered an issue using Type.GetProperties on a COM object when running under .NET 3.5 & .NET 4.0.
The following code uses the Microsoft Scripting Runtime COM object as an example - it has the same behaviour with any COM object I have tried. Under .NET 3.5, it correctly returns an array containing one property (the Drives property). Under .NET 4.0, it returns no properties.
Scripting.FileSystemObject fs = new Scripting.FileSystemObject();
Type t = fs.GetType();
PropertyInfo[] props = t.GetProperties();
Type.GetProperties seems to work correctly on .NET objects and only seems a problem with COM objects.
I have some generic code that sets property values by using a string variable as the name that works in .NET 3.5 and now fails in .NET 4.0.
I know that I can upgrade the code to use the dynamic type in .NET 4.0 to do this BUT why is this not backwards compatible or at least documented in some way that is easy to find?
Kind regards
Andy
|
|
|
|
|
Sorry to state the obvious, but since Microsoft are the providers of this software, I believe they are best qualified to answer your question.
I must get a clever new signature for 2011.
|
|
|
|