|
Hello,
An interface will help you.
Search here on CP for Articles about the usage of interfaces!
All the best,
Martin
|
|
|
|
|
first - what is your problem , be more Specific.
if you don't know how to connect to a data base
then bye a book or use google
second - delete the previous posts before they kick your a**
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Butt kicking mode activated.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
jus i want code for accessing MS- Access tables from windows forms in c#. dont excite ok?
|
|
|
|
|
mind ur language. ok?
|
|
|
|
|
easy easy.......
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
How to monitor an object in program ? When that object changes, I want to receive an event to do something.
Thank a lot.
imagic
|
|
|
|
|
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....
|
|
|
|