|
I'm fairly new to C# and WinForms programming.
How does one programmatically "select" a node in a TreeView.
IE: the user clicks a button which spawns a child process, the output of which is displayed in a TextBox. Each time the user clicks that button, a new process is kicked off and I attach a new node to the TreeView to represent said process. If the user clicks on any given node, that node's associated process output TextBox is brought to the foreground - whre you can watch the output.
Adding the node to the TreeView is straightforward, but hilighting it or "selecting" it programmatically is not so easy.
Suggestions?
-Luther
|
|
|
|
|
Isn't there a:
treeview.setActiveNode(node) method?
if you create the node as a variable first, then add it, and set the variable to the active node, it should do it.
I had this problem with seting the active node of a tree view when it first gets control.
Cata
|
|
|
|
|
Active and Selected are two completely different things. Active just means that the node has the focus, such as what it gains when you right-click the node. Selected means that the node has been left-clicked at some point. To select a node programmatically, just use the following:
treeview.SelectedNode = someNode;
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
That's what I was looking for.
|
|
|
|
|
The obvious escaped me.
Thank you both.
-LutherB
|
|
|
|
|
After doing this - indeed the "selected" image appears to the left of the tree node (from the ImageList index used when creating the node) but, the actual text of the node is not "highlighted. IE: the folder opens, but the folder name is not highlighted.
This is even more obvious when working with a ListView. I've selected a particular ListViewItem, but no rectangular, reverse color block around the text of the item appears onscreen.
Maybe I am doing something wrong - or missing something? Without the highlighted text, its not really obvious which element has been selected.
Thanks,
-Luther
|
|
|
|
|
Out of curiousity, does the rectangular marquee (the dotted lines) around the text appear? If so, the TreeView no longer seems to have the focus. Set TreeView.HideSelection to false and see if the rectangular selection region is at least gray (or whatever the default system color for inactive selected text is).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Excellent - a grey "highlight" block appears around the text now - for both the visible ListView and TreeView.
Its not the normal (per my theme) "blue" highlight, but its a clear indication to the user - which is my real goal.
Thanks Again,
-LutherB
|
|
|
|
|
Aha ...
I understand now. Makes perfect sense. The issue of "focus" that is.
One more line, TreeView.focus() does the final trick.
Thanks,
-Luther
|
|
|
|
|
I'm trying to run midl, however, I am encountering error after error.
Cl.exe was not located in the correct location.
when i moved it, there was no mspdb70.dll to support CL.exe.
These components were all in different folders.
Is this right? Or is my instalation of .NET completely knackered?
Is it worth moving all the tools and associated DLL's into one directory? As it's really annoying.
Cata
|
|
|
|
|
I've copied all the stuff in the Vc7\bin folder to the common7\tools\bin folder.
I've moved the objidl.idl file into the tools\bin directory.
It's still not building objidl.idl. I get the error "Cannot open unkwn.idl"
help!
Cata
|
|
|
|
|
What does your .idl file look like?
- Nick Parker My Blog
|
|
|
|
|
its the objidl.idl file, taken from the platform SDK Folder in VS.net.
I'm moving the post to the COM forum.
My bad.
Cata
|
|
|
|
|
This is not C# any more, move to the COM forums. ANyways, you are getting that error because your command enviroment is not setup correctly.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Which is why I've been trying to get Catalyst to understand that in a separate thread. I mean, if you can't even understand environment variables, why would anyway think to tackle COM? That's like trying to climb Everest or K2 without making it up the front steps to the lobby (if it has one?)!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Just run the vcvars32.bat found in "Microsoft Visual Studio .NET 2003\Vc7\bin" in the command line before trying to run MIDL
|
|
|
|
|
I'd like to use the TlbImp.exe program to build some managed COM objects. This seems to be the most efficient way of doing things.
The problem I have is that, what I am looking for resides in the objidl header file. DOesn't this compile to a DLL?
While there are many type libraries, I do not know which one would contain the data I need, if any. Which would it be?
If they are not located there, How do i extract data from an unmanaged DLL?
Cheers
Cata
|
|
|
|
|
Sorry, little more information here.
This relates to my Drag Drop problem. Basicaly, I'm looking for the COM classes used for the process to convert them into managed times. I'm not even sure I have the right one.
It looks like the Object Information Data Librarby class.
When I attempt to extract the library definitions from ole32.dll, I get the error: "Unable to locate input type library"
Cata
|
|
|
|
|
If you want to do things this way, you must create an IDL file (don't use headers and don't worry about compiling to a DLL) and import additional IDL files when necessary. Interface documentation should list what IDL file they are found in. If not, check for a similar IDL file that matches the name of the header file (filename.h to filename.idl).
Take a look at the following CP article which gives an example of how to go from IDL files -> midl.exe -> typelib -> tlbimp.exe -> interop assembly: Using MSHTML Advanced Hosting Interfaces[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
Take a look at the following CP article which gives an example of how to go from IDL files -> midl.exe -> typelib -> tlbimp.exe -> interop assembly: Using MSHTML Advanced Hosting Interfaces[^].
You beat me to it, I was looking for the link to that article to post a reply and thought I would check to see if you had posted a reply yet.
- Nick Parker My Blog
|
|
|
|
|
Thanks.
I just realised I've been looking for all my DLL's etc in my windows directory, when i have all the base source code in my VS SDK.
About ready to kick myself over that one.
By the way, I'm trying to navigate through dos, and I can't open the long windows file names. A lot of mine have spaces in, and I can't get into the VS directory.
I've looked at a number of dos sites, but it's bugging me. How do I do this?
Or is there an easier way of moving all source code into a low level directory with the tool exe's that i'm using?
Cheers
Cata
|
|
|
|
|
Wrap your path in quotes any time it has spaces. This has been the case since Windows 95 and applies to any other shell (like bash, csh, tsh, etc. in *nix)!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Currently I am pulling all the classes I need relating to drag and drop from the IDL's in the SDK, and packing them into my own custom one.
Is this the right thing to do?
Also, when adding an interface to my IDL, do i need to include the square bracketed section above it that looks like:
[
object,
uuid(0000010e-0000-0000-C000-000000000046),
pointer_default(unique)
]
I think I do, but i'm not sure.
Also, can I add enumerations and structures to this? Or is it only interfaces?
Cheers
Cata
|
|
|
|
|
First, add the paths to your INCLUDE enviroment variable and you won't have to worry about paths.
Second, no, you shouldn't include the interface information - they're already defined you're just forward-defining them.
There's plenty of information about IDL in the PSDK. You should read some of that. Also, just do what the author did in the article that I linked. He does everything you need to do, just with different IDL files, interfaces, and structs.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
What's the INCLUDE enviroment variable? I have never encountered this before. Where does it go? Is this in VS?
I don't need to add the square bracketed stuff? In the article the guy uses only the UUID number in the interfaces he uses in his IDL file.
Unfortunately, while i have the platform SDK source code, I don't have the documentation to go with it. I'll have a gander on the MSDN though.
Sorry to keep asking sometimes dumb questions, but by almost all standards, I am a programming novice, and acronyms and half the names of things don't mean anything to me.
Cheers
Cata
|
|
|
|