|
Thank You.
I have been trying to this for 3 days now but still no luck.
Do you were i can find a good Example for 3 treeviews that connect to a Sql Server. Using either diffrent Database or the same database using tables inside the same database.
If that Makes any sense
If not then Thank You.
You Guys are Great
I like this Forum
|
|
|
|
|
craigMUTOKOKAI wrote: Do you were i can find a good Example for 3 treeviews that connect to a Sql Server.
You're going about this the wrong way. You're trying to find an example of using 3 treeview with SQL server. What you really have is a single treeview, which you said you already got working, and repeating the same process 3 times.
|
|
|
|
|
Oh okay thank You.
What i was trying to do is to create a class to connect to the Server.
And then use that class in the 3 treevies that i have so that they can connect to the database an populate thier own table.
Like
Treeview 1 = Golf
database table= golf
Treeview 2= tennis
database table=tennis
Treeview 3=Basketball
Database Table = Basketball
An the Database instace will be called Sports.
So i want to connect these Tables to the same Database but to use thier own tables in the database to populate the treeview.
I hope im making sense.
Can you help me create this class and call the class whithin the Treeviews.
i hope im no stressing you out.
If i am very Sorry
|
|
|
|
|
Just as I said in the first place, and Dave has repeated, just treat them as 3 individual treeviews. You have said you have 1 working, so repeat the process for each of the others. The connection to the database is the same, you are just selecting from different tables. Try reading up on datareader and dataset as these are the things you are really using.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
J4amieC wrote: After flooding the forum with no less then 4 near-identical posts, I dont think anyone is going to be in the mood to help you.
He posted it four times just to show how urgent the problem is
|
|
|
|
|
he needs lots of help
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
What im trying to do is to link the Treeview to the List view.
I have the Treeview linked to the database already and i want it so that when i click on a node it will display in the List View.
Does any one know how to do this?
If so please Answer my Question
|
|
|
|
|
Don't flood the forums with the same questions.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
What im trying to do is to link the Treeview to the List view.
I have the Treeview liked to the database already an i want it so that when i click on a node it will display in the List View.
Does any one know how to do this?
If so please Answer my Question
|
|
|
|
|
How have you attached the database to your tree view control?
You can add an event handler to the tree view to intercept when the currently selected node has changed. Then, depending on how you've got things set up, you could possibly:
#1 - Look up the required data from the database by the ID associated with a tree view node.
#2 - Extract the information from the selected tree view node.
Don't forget that you can use the 'Tag' property of tree view nodes, so you could associate your data using the Tag property. Then it is very easy to access your information. In your selected node changed event handler you can simply populate your list view from the associated 'Tag' property, or even acquire additional information from your data source using the information provided by the 'Tag' property.
I hope that I have understood you correctly, and that this is of some use.
Best regards,
Lea Hayes
|
|
|
|
|
Afternoon everyone. Crap weather we're having today...
Now then, what's going on here?
using System;
namespace Confusion
{
public delegate void ThingDelegate();
public abstract class A
{
public virtual void Thing()
{
Console.WriteLine("A::Thing");
}
}
public class B : A
{
public override void Thing()
{
Console.WriteLine("B::Thing");
ThingDelegate del = base.Thing;
del.Invoke();
}
}
public class C : A
{
public override void Thing()
{
Console.WriteLine("C::Thing");
ThingDelegate del = base.Thing;
del.BeginInvoke(null, null);
}
}
class Program
{
static void Main(string[] args)
{
B b = new B();
b.Thing();
Console.ReadLine();
C c = new C();
c.Thing();
Console.ReadLine();
}
}
}
If you run this simple console application what's the output? If you're as dim as me, you'd expect:
B::Thing
A::Thing
C::Thing
A::Thing
What you actually get is:
B::Thing
A::Thing
C::Thing
C::Thing
C::Thing
...
... to infinity and beyond.
eg. Invoke and BeginInvoke resolve to different methods. Can anyone explain why?
Regards,
Rob Philpott.
|
|
|
|
|
BeginInvoke uses the thread pool. Invoke is the same as calling del();
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Agreed, but that doesn't explain the disparity between the two.
Regards,
Rob Philpott.
|
|
|
|
|
Which one is not being called? Right special code to see if it is the invoke or Begin invoke that is not firing. The easiest way is to specify a callback method. And then you can determine why you do not get two A's in the output.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
I tried your code and it effectively seems that Invoke and BeginInvoke behave differently. Invoke seems to take the address of the base's method, while BeginInvoke seems to take the address of the child's method, hence the infinite loop. Probably something to do with threading.
Well, good catch. Now, you will know in what circumstance not to use BeginInvoke.
Btw, I don't know in which context you wanted to use this, but you probably should review your design.
|
|
|
|
|
Thanks for the reply!
Review the design? I'd quite agree but I'm trying to fix an infinite loop bug in someone elses code. Personally I'd steer clear of anything with a complicated parent/child relationship and asynch processing but that's what I've got.
Regards,
Rob Philpott.
|
|
|
|
|
This puzzled me, so I decided to do some digging to figure out what was happening. Just to warn you thought, I still haven't got a clue what is going on, but I thought I'd share what I looked at with you, maybe you'll spot something I missed.
First thing I tried was looking at the compiled assemblies in reflector.
B:
ThingDelegate del = new ThingDelegate(this.Thing);
del();
C:
new ThingDelegate(this.Thing).BeginInvoke(null, null);
As you can see, they are slightly different. In both cases, the delegate assignment is expanded to use the constructor. (Obviously, the assignment you are doing is just short hand for calling the constructor). What's odd though is that with B, the variable 'del' is kept, but with C, the compiler removes the variable and just calls BeginInvoke directly after creating the delegate. This could just be an artefact of the way reflector rebuilds the code though, we'll have to look at the IL to see.
You can also notice that in both cases, your reference to base.Thing is changed to this.Thing. Which I find a bit strange. To me, this implies that both calls should behave like C, and go into infinite recursion.
Next I took a look with ILDasm
B:
IL_000c: ldarg.0
IL_000d: ldftn instance void Confusion.A::Thing()
IL_0013: newobj instance void Confusion.ThingDelegate::.ctor(object,
native int)
IL_0018: stloc.0
IL_0019: ldloc.0
IL_001a: callvirt instance void Confusion.ThingDelegate::Invoke()
IL_001f: nop
IL_0020: ret
C:
IL_000c: ldarg.0
IL_000d: ldftn instance void Confusion.A::Thing()
IL_0013: newobj instance void Confusion.ThingDelegate::.ctor(object,
native int)
IL_0018: stloc.0
IL_0019: ldloc.0
IL_001a: ldnull
IL_001b: ldnull
IL_001c: callvirt instance class [mscorlib]System.IAsyncResult
Confusion.ThingDelegate::BeginInvoke(class
mscorlib]System.AsyncCallback, object)
IL_0021: pop
IL_0022: ret
Ok, so what's the difference here. The both start with ldarg.0 instruction. This basically pushes the "this" pointer for the current object onto the stack. Then they both do a ldftn which pushes an unmanaged pointer to the method A.Thing() onto the stack (as a native int).
Next they both call the delegate constructor. Which uses the 'this' pointer and A.Thing() pointers that we just pushed (The object and the native int in the brackets)
The next two lines (stloc.0 and ldloc0) basically pop the newly created ThingDelegate off of the stack an into storage index 0, then back onto the stack again ready to be used.
C then has 2 calls to ldnull which simply loads a null pointer onto the stack (for you two null passes to BeginInvoke).
The next line (callvirt) is the call to either Invoke or BeginInvoke. As you can see, we've created the ThingDelegate exactly the same way, and the calls are exactly the same.
finally, C has a pop command to get the IAsyncResult return object off of the stack (and B just does a no-operation), then both return nothing (ret).
Ok, so what's the difference? Nothing as far as I can tell.
Both have been compiled in exactly the same way. Both have created the ThingDelegate using a pointer to this and the A.Thing() method.
The only difference is that one calls Invoke and the other calls BeginInvoke.
My next step was to look at the ThingDelegate itself. In reflector you can see that it extends from System.MulticastDelegate. Basically it declares virtual methods BeginInvoke, EndInvoke and Invoke. You can see exactly the same if you look at the IL.
So where does this leave us? I'm still confused. It seems that the runtime handles the Invoke and BeginInvoke calls. I've used reflector on the MulticastDelegate type and it doesn't even have Invoke or BeginInvoke methods, they are only defined in the ThingDelegate type. I would assume that somehow the call is ultimately directed to the DynamicInvoke method on the base Delegate type, but I've no idea how that happens, or why it's different for the two types of invoke.
I'm totally confused by this. If you ever work it out, please let me know.
Good luck.
Simon
|
|
|
|
|
Wow, that's some digging. Thanks for the reply.
I've sort of concluded the following, but it may all be wrong.
The Invoke method effectively just calls the method on the same thread so could be replaced with base.Thing(), which calls the base class just as you'd expect.
BeginInvoke though on an instance delegate having a 'this' pointer referring to the child class seems to be activating the polymorphic mechanism and determining that Thing() is overriden and using the override instead. It's kind of valid.
So I guess the difference is that Invoke just calls a method, but BeginInvoke will call the method or preferentially any override. It is an odd one though, because one naturally assumes they'd call the same method ultimately.
Thanks again for your help.
Regards,
Rob Philpott.
|
|
|
|
|
Guys,
I am taking some classes and I am trying to do assignm,ent in c#. I have a question. I have the asignment that must use the LInked Lists so I was wondering if c# has any think like Linked Lists in C++? Please advice and I will greately appreciate your comments.
Thank you and God bless you all for wonderful help!
|
|
|
|
|
Yeah, umm....surprise surprise, it's called LinkedList[^]
It's a generic so you can use it with whatever type you want.
Simon
|
|
|
|
|
There's a LinkedList class in .NET 2.0.
Kevin
|
|
|
|
|
There is such thing called Google that let's you to search. Have you tried it? There is also MSDN too.
|
|
|
|
|
sorry, but if google had it all, this forum will no longer be needed. google searches forums like this. If you have no answer to it better not to response. Noone is born nice and kind but kindness can be earned. Respect yourself and respect others.
|
|
|
|
|
nesfrank wrote: sorry, but if google had it all, this forum will no longer be needed.
I agree, Google does not have everything but it does have much information. You use documentation and books to learn about something and post on forum if you can't need to clarify some points or need more help.
nesfrank wrote: Respect yourself and respect others.
So why don't you respect us and do basic search and read documentation? Most of the questions asked at this forum can be answered by reading documentation and doing simple search. I guess some people are too lazy to do that.
|
|
|
|
|
thanks anyway. I appreacute any answer
|
|
|
|