|
Hello,
Make an property out of your object and fire your event in the properties setter, if the value changes.
private object _yourobject;
public object YourObject
{
get
{
return _yourobject;
}
set
{
if(value!=_yourobject)
{
_yourobject = value;
}
}
}
All the best,
Martin
|
|
|
|
|
One idea is to use the property (set and get)
EX:
public class testClass
{
public int s1 = 0;
public int s2 = 0;
public int s3 = 0;
}
private testClass Mumu=new testClass ();
public testClass mumu
{
set
{
MessageBox.Show("bingo");
Mumu = value;
}
get
{
MessageBox.Show("bingo");
return Mumu;
}
}
................
private void button2_Click(object sender, EventArgs e)
{
mumu.s1 = 10;
}
|
|
|
|
|
Sorry, my question isn't clear.
I have 2 programs A and B: program A monitors program B. When value of object in that program B changes, program B will receive event to do something.
Thanks a lot.
imagic
|
|
|
|
|
Hello,
What do you mean with "program"?
A class or an project?
All the best,
Martin
|
|
|
|
|
Martin# wrote: What do you mean with "program"?
A class or an project?
An independently running process is the general meaning of "program"
|
|
|
|
|
That's what I thougt, but I whanted to make sure if the question is asked correct.
Asking a question in a foreign language is often very difficult, as I know from myself.
But thank's for your statement.
All the best,
Martin
|
|
|
|
|
Thanks Martin.
I mean it be solution. It like a debug program (A) that monitor program (B).
Perhaps, I'll try server-client and get-set to do what I want. But, it isn't reasonable because we don't want to add too much code in solution (B)
Thanks you for your regard.
imagic
|
|
|
|
|
Hi,
I'm using Xmlreader to load XML and in the event that the server is down, to try another server. Below is snippets of the code:
foreach (System.Xml.XmlNode Addr in LinkAddr)
{
string link=Addr.Value.Tostring();
try
{
XmlReader reader = new XmlTextReader(link);
}
catch(system.net.webexception)
{
link=link.replace("AAA","XXX"); //replaces one server with another
XmlReader reader = new XmlTextReader(link);
}
finally
{
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: ....
however, I get the error "The name 'reader' does not exist in the current context".
What should I do?One way I thought of is to put XmlReader reader=new XmlTextReader(link) in the finally block but will this result in waste of resource to load the page a second time after loading at either the try or catch block? I am new to c# and is using VS2005 with .NET 2.0. Thanks.
|
|
|
|
|
The problem is that you are declaring XmlReader reader in the try/catch blocks. Variables that are declared in these blocks cannot be seen in the finally section. What you need to do is declare reader before the try, so it becomes:
XmlReader reader = null;
try
{
reader = new XmlTextReader(link);
}
catch (WebException)
{
link = link.Replace("AAA","XXX");
reader = new XmlTextReader(link);
}
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks. I believe it worked. Thanks.
|
|
|
|
|
Is there a generic adapter for collection that allows to map a colleciton of an object to e.g. a collection of members?
e.g. I have an IEnuemrable<ListViewItem> and want to turn this into an IEnumerable<object> holding the ListViewItem.Tag objects.
I toyed with writing a generic adapter IEnumerable<foo> to IEnumerable<bar> using a bar translate(foo f) delegate. But doing that for Enumerations, collections, ILists, ... involves a lot of generics, making my nice beautiful C# code look like template hell.
|
|
|
|
|
Hey!
I have a listview that gets filled with items which sometimes are updated. Every item gets a vlue in their tag-field. I was wondering if anyone knows of a very fast way of searching through these tags? My list can sometimes become pretty large why updating it takes a lot of time.
Best regards,
Hampus
|
|
|
|
|
Helloo all
am using xmltextWriter to write node in xml file
XmltextWriter w=null
w=new Xmltextwriter(-----);
but the problem not in using writer
the problem is
I have listbox have this values
----------
Level1
Level2
Level2
Level2
Level3
Level3
Level1
Level2
Level3
Level4
Level2
Level2
-----------
and soon on
i want to make witer get values for list and write it to xml
every level1 present base node(root node) and sublevels is subnodes
i want be unlimeted level
xml file show be appear like this
<root>
<level1>
<level2/>
<level2/>
<level2>
<level3/>
<level3/>
</level2>
</level1>
<level1>
<level2>
<level3>
<level4/>
</level3>
</level2>
</level2>
</level2>
</level1>
</root>
tkml
|
|
|
|
|
You forgot to tell us what the concrete problem is. If that is by intention and you expect someone to give you the complete code, you're almost certainly not getting lucky. Try it yourself, show us the code you got, tell us where you get stuck and we'll be pleased to help you.
"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
|
|
|
|
|
I'm busy developing an event logging system as part of my current project. I would very much like to make use of log entry data, such as event ID, event category etc. to enable better use of the event data, for example, I can possibly use an event category to select a parser for the event data etc.
So far I have found almost zero resources on the strategic design questions regarding the use of these fields. Has anyone come across such information, or do I really have to start from scratch and invest serious effort into this as a long term goal. Then it would possibly add value as a strategy for enterprise level use, not application specific.
|
|
|
|
|
hi everyone,
is there any way through which i can send sring data to a parallel port using C#.net... thanks in advance...
|
|
|
|
|
Hi
yes there is. you can open the Parallel port open as a file and use FileStream to write on it.
something like this:
<br />
public class ParallelWriter<br />
{<br />
public const UInt32 FILE_FLAG_OVERLAPPED = 0x40000000;<br />
public const UInt32 OPEN_EXISTING = 3;<br />
public const UInt32 GENERIC_READ = 0x80000000;<br />
public const UInt32 GENERIC_WRITE = 0x40000000;<br />
[DllImport("kernel32.dll", SetLastError=true)]<br />
private static extern IntPtr CreateFile(String lpFileName, UInt32 dwDesiredAccess, UInt32 dwShareMode,<br />
IntPtr lpSecurityAttributes, UInt32 dwCreationDisposition, UInt32 dwFlagsAndAttributes,<br />
IntPtr hTemplateFile);<br />
private FileStream strm;<br />
public FileStream Stream<br />
{<br />
get<br />
{<br />
return strm;<br />
}<br />
}<br />
public ParallelWriter(string Port)<br />
{<br />
IntPtr Handle = CreateFile(Port,GENERIC_READ|GENERIC_WRITE,0,IntPtr.Zero,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,IntPtr.Zero);<br />
strm = new FileStream(Handle,FileAccess.ReadWrite,true,1,true);<br />
}<br />
}<br />
now just use the Stream to write your data to the Parallelport
greets
m@u
|
|
|
|
|
hi,
thanx for ur response.. After getting the strm how will i connect to parallel port to send this data... can u give me the code for the parallel port connection....
|
|
|
|
|
Hello everyone,
I have a ListView which is populated by a CSV file. Using program I am going to select one of the rows in the ListView.
I have questions and I will be greatfull if someone can tell me how I can achieve it.
Question 1: How can I change the row's color "Similar as when it is clicked by mouse" when the program pick a particular row?
Question 2: The list of data is very long and not all of it can be placed in the ListView window. Is it possible to move the list and make sure the picked row with be somewhere in the middle of the ListView window, visiable to the user?
Thank you very much and have a good day/night.
Khoramdin
|
|
|
|
|
1) In the listview there is event like ColumnClick. It's parameter (e) is the column number. Try using this parameter with the colum color.
2)Try using property "ListName".AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
One nation - underground
|
|
|
|
|
I am using a Symbol device and my application pre-requisites include installing the symbol.all.arm.cab on the device.
The first time I installed the pre-requisites and the application on the device, the application ran properly without any crash.
But later, when I tried to start the application again, there was an error seen and the application did not start.
The following error was seen
TypeLoadException
Could not load type
Symbol.Generic.Reader from assembly Symbol,
Version=1.0.5000.3, Culture=neutral, PublicKeyToken=68EC8DB391F150CA.
MSDN says “TypeLoadException is thrown when the common language runtime cannot find the assembly, the type within the assembly, or cannot load the type.”
I tried reinstalling the ‘symbol.all.arm.cab’ file again, but it gives the same error.
can anyone help me in understanding why am I getting this error and what should I do to correct it.
|
|
|
|
|
Hey all,
I'm writing a program that can modify packets in c#.
Everything is going fine except my TCP checksum generator where it seems to work for some packets but with a few slight changes it generates the wrong thing. It only seems to be doing this when sending packets to my test box, otherwise it works fine.
Could the community please have a look at my code and try and find out what is wrong? i know my programming style Isn't exactly neat although any help would be appreciated.
I pass it the whole packet and it sends back a string of the checksum in hex format.
Cheers
-Glen
<br />
private static string GenerateTCPChecksum(byte[] packet)<br />
{<br />
packet[0x32] = 0x00;<br />
packet[0x33] = 0x00;<br />
<br />
int sum = 0;<br />
string ipHeaderLength = Convert.ToString(packet[0x0e], 16);<br />
ipHeaderLength = "" + ipHeaderLength[1];<br />
int packetSize = Convert.ToInt32(Convert.ToString(packet[0x10], 16).PadLeft(2, '0') +<br />
Convert.ToString(packet[0x11], 16).PadLeft(2, '0'), 16);<br />
int length = packetSize - (Int32.Parse(ipHeaderLength) * 4);
<br />
for (int i = 0x22; i < packet.Length; i++)<br />
{<br />
try<br />
{<br />
sum = sum + Convert.ToInt32(Convert.ToString(packet, 16).PadLeft(2, '0') +<br />
Convert.ToString(packet[i + 1], 16).PadLeft(2, '0'), 16);<br />
}<br />
catch (IndexOutOfRangeException)<br />
{<br />
sum = sum + Convert.ToInt32(Convert.ToString(packet, 16).PadLeft(2, '0') + "00", 16);<br />
}<br />
i++;<br />
}<br />
<br />
sum = sum + (Convert.ToInt32(Convert.ToString(packet[0x1a], 16).PadLeft(2, '0') +<br />
Convert.ToString(packet[0x1b], 16).PadLeft(2, '0'), 16)) +<br />
(Convert.ToInt32(Convert.ToString(packet[0x1c], 16).PadLeft(2, '0') +<br />
Convert.ToString(packet[0x1d], 16).PadLeft(2, '0'), 16)) +<br />
(Convert.ToInt32(Convert.ToString(packet[0x1e], 16).PadLeft(2, '0') +<br />
Convert.ToString(packet[0x1f], 16).PadLeft(2, '0'), 16)) +<br />
(Convert.ToInt32(Convert.ToString(packet[0x20], 16).PadLeft(2, '0') +<br />
Convert.ToString(packet[0x21], 16).PadLeft(2, '0'), 16)) +<br />
0x06 + length;<br />
string s = Convert.ToString(sum, 16);<br />
string carry = "00";<br />
if (s.Length >= 5)<br />
{<br />
carry = s.Substring(0, s.Length - 4);<br />
s = s.Substring(s.Length - 4, 4);<br />
}<br />
sum = Convert.ToInt32(s, 16);<br />
sum = sum + Convert.ToInt32(carry, 16);<br />
sum = 0xffff - sum;<br />
s = Convert.ToString(sum, 16).PadLeft(4, '0');<br />
return s;
}
|
|
|
|
|
Hi all,
I am using the zedgraph control in my current project in which i am using zedgraph as a graphing area,
here i am plotting the line graph dynamically(ie., when the user clicks on the graph pane the points r created and the graph is drawn). According to our project requirement if the user selects a point it should be highlighted by dispalying a different color for that point so i am repainting the graph with a different color of the selected point this works fine but when selecting more than one point all selected points should be highlighted wher i am facing the problem. when i am passing all the selected points index and trying to highlight them its is working but on mouse click i am unable to get the desired o/p may b some where it is repainting i think.
Thanx in advance
prashanth
|
|
|
|
|
I'm guessing that you should post this against the article on ZedGraph. The author is probably your best bet for answering this one.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I want a DataGridView property in my UserControl:
C#<br />
<br />
public DataGridView _DataGridView<br />
<br />
[Category("Data"), DefaultValue(null)] <br />
public DataGridView DataGridView<br />
{<br />
get { return _DataGridView; }<br />
set { _DataGridView = value; }<br />
}<br />
I put the user control on a form, and this property shows (none) by default. I assign a dataGridView1 to the property.
But, when I delete dataGridView1, the property does not revert to (none). I can even still press the [+] and traverse as if the property was still referring to something.
I've looked everywhere (documentation, msdn, and searched the web) for any example demonstrating how to define a property to exhibiting the correct behavior.
The correct behaviour is exhibited by the ContextMenuStrip property of a Control, where it reverts to (none) when a contextMenuStrip1 is assigned to it and then deleted.
I'm new hear, so please forgive me if this query's been resolved, and point me in the right direction.
Thank you for your attention,
S
-- modified at 14:54 Thursday 29th March, 2007
|
|
|
|
|