|
-
July 19th, 2006, 05:04 AM
#1
C# for the C++ guy...
Hello,
now it happend: I have to participate in a C# project.
I am good in C++ (worked for 6 years in C++), but I have never done anything in C# or even in VS 2005.
The assignment is: I have to write a control which looks like a tree but has instead of the normal tree items a few cells (like a row in a grid).
It should look something like this:

I have a grid control which I wrote myself and in C++ I would derive a class from CTreeCtrl and use my cells as the treeitems.
Anything like this possible in C#? Can I "import" my grid classes in C# and use them or should I start entirely from scratch?
Perhaps someone has a few hints.
Robin.
-
July 19th, 2006, 10:47 AM
#2
Re: C# for the C++ guy...
C# is pretty easy if you have C++ experience, you just have to learn some of the differences, such as the way you initiate arrays. You could probably use your control you wrote in C++ indeed, through InterOping/Marshalling, though I don't know much about those things yet. You might have a better time writing it from scratch, since .Net is very helpful, it'd be a breeze, nothing compared to the long and boring way of C++. Just learn about control creation and you should be well on your way.
-
July 19th, 2006, 03:48 PM
#3
Re: C# for the C++ guy...
 Originally Posted by blankdev
You might have a better time writing it from scratch, since .Net is very helpful, it'd be a breeze, nothing compared to the long and boring way of C++. Just learn about control creation and you should be well on your way.
ok I looked into it as your post sounded very promising, but I haven't got a clue. How can derive a class from something like CTreeCtrl (I couldn't find that is there an aquivalent)?
Robin
-
July 19th, 2006, 03:59 PM
#4
Re: C# for the C++ guy...
 Originally Posted by robin83
ok I looked into it as your post sounded very promising, but I haven't got a clue. How can derive a class from something like CTreeCtrl (I couldn't find that is there an aquivalent)?
Robin
Just by looking at your block diagram and seeing your CTreeCtrl command, I think you should look into TreeView and ListView. I'm not sure the difference between the two, but I just started looking at TreeView. Its the basic window explorer style when displaying the directories. How would you make it like your diagram, I have no clue. Again, I just started playing with TreeView recently.
-= the best is yet to come =-
-
August 1st, 2006, 05:33 PM
#5
Re: C# for the C++ guy...
ok, now I am officially clueless. The thing that makes the project even harder (for me) is the target platform: it has to run on a pocketpc.
I tried to work with TreeView, but I could not override OnPaint. It simply gets not called. WinProc is unknown, although some examples use it. Even if I could work with OnPaint, I do not know what to do with it, as it is only provided in TreeView, not in TreeNode as I would have expected.
I hope somebody can help?
Robin
-
August 2nd, 2006, 05:27 AM
#6
Re: C# for the C++ guy...
I'd have an owner drawn ListView (or ListBox even) and do your own drawing of each of the leaves.
Darwen.
-
August 2nd, 2006, 06:08 AM
#7
Re: C# for the C++ guy...
So that is my only chance then? I have to write my own treeview control, to take care of the drawing of the nodes, correct?
-
August 3rd, 2006, 04:00 AM
#8
Re: C# for the C++ guy...
There are quite a few examples of this kind of control about, most seem to override ListView and add the Tree functions rather than the other way around. Try TreeListView for a starting point.
-
August 3rd, 2006, 05:11 AM
#9
Re: C# for the C++ guy...
Hi,
For a C++ guy moving to C#, i'd suggest GDI+ first. If u have an
understanding of GDI+ , its quite easy to draw custom controls (owner draw).
Its better not to mix managed code (C#) and unmanaged code (C++) as
long as u can avoid it. The interop issues are a headache and u'll slowly
fall into the wrong groove.
C# has a lot of easy to use classes and for a C++ guy with a lot of
experience like u can adapt to C# in a jiffy All Luck.
-
August 3rd, 2006, 08:44 AM
#10
Re: C# for the C++ guy...
I've seen folks do that type of thing w/ the .net 2.0 data grid view control.
-
August 3rd, 2006, 01:06 PM
#11
Re: C# for the C++ guy...
Yes I think luck and a little bit of effort was all I needed.
Yesterday night and today I wrote my one control. It needs a little bit tweaking here and there but the basics (including owner draw of the nodes!!!!) is ready!!!!
Thanks for your help
-
March 20th, 2007, 06:23 PM
#12
Re: C# for the C++ guy...
hi,
i realise this is an old post, but would you be able to post the code you used? i have been trying to do this for a while, and i keep hitting brick wall after brick wall
or even just a pointer in the right direction
cheers
adam
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|