|
What I'm trying to do is have a tree view on the left of my SDI view, and depending on what's selected in that, display a different "form" or view on the right hand side. I'll want to have a dynamic amount of views, depending on how many items are in the tree view. All the data in the different views will be updated constantly, but only the selected one will display.
Any ideas how to accomplish this?
The Tab Control looks promising, but I'm wondering if there's another way, and I don't want the actual tab, because selection will be done via the tree control.
Thanks,
Peter
|
|
|
|
|
All you need to do is associate a Type with your TreeNode and create an instance of that when needed. You could also instantiate an instance with each TreeNode , but that would make memory consumption very high (depending on how many TreeNode s you have).
For example, derive from TreeNode with your own class and add a ControlType property (or whatever you want to call it) of type Type . In the handler for the TreeView.AfterSelect method, you can do something like this:
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
Type t = ((MyTreeNode)e.Node).ControlType;
Control c = (Control)Activator.CreateInstance(t);
containerControl.Controls.RemoveAt(0);
containerControl.Controls.Add(c);
} The containerControl represents the Panel or whatever hosts the control to be created in your form on the right side. Please note that this is a very simplistic example but should give you some idea.
There's also a few articles here on CodeProject that use a similar approach for tree-driven preference dialogs/controls. For one example, see A Designable PropertyTree for VS.NET[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks, that's exactly what I needed.
Peter
|
|
|
|
|
But is there a way of preventing the tab from drawing?
(I have a similar problem that has to do with the CrystalReportViewer. I'm trying to customize the control more than it allows. It would be great if I can just take the control and parent it to a panel, but part of the implementation is in the tabcontrol so that didn't work out.)
|
|
|
|
|
You could override WndProc and pretty much change the behavior of the TabControl to work like multiple Panel s (after all, you're just making each TabPage work like it's parent class, ScrollableControl , which is the parent class for Panel ). Why not just move the implementation? Most of the code I'm sure you could copy and paste, unless you mean you're actually using the tab-related methods for things (like for a wizard), in which case there's always another way.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The problem here is that I don't want to go trough the pain of redoing the implementation. I can modify the properties of the provided CrystalReportViewer control. Thanks for the suggestion. I'll just implement a message filter and do the needed work myself.
The components that make up the CrystalReportViewer controls are public. It's just that I don't know enough about the internal implementation to create my own implementation. If there is an example of a custom implementation please give me a pointer.
|
|
|
|
|
I know this belongs in the VS IDE forum, but it appears no questions get answered there.
I have a Visual Studio solution that contains 2 projects. ProjectA is a Windows Control library, while projectB is a Windows Forms application project. In projectB, I add a reference to projectA and place the control (projectA) on the Windows Form (projectB). All is fine and dandy. However, when I make a change to the control in projectA, it doesn't update the control instance on the form of projectB, unless I remove the reference to projectA and then add it again.
What do I need to do so that projectB (the form) always has the latest version of projectA (the control)?
The graveyards are filled with indispensible men.
|
|
|
|
|
When you make a change to the control, build the solution, or at least ProjectB (the app). Close (if not already) the form that contains the control and reopen it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yeah for some reason that doesn't work. I've done an easy test: setting the .BackColor of the control, rebuilding the solution, then opening the form designer for the app, yet the back color of the control remains the same.
The only way the back color gets updated is if I remove the reference to the control, then add it again...bizarre.
I think it may be related to another problem I'm having - during a solution rebuild, some of the other libraries output "Could not copy xyz to run directory. The file was in use by another process." Oddly, there shouldn't be any processes using these files.
The graveyards are filled with indispensible men.
|
|
|
|
|
Ahh yes, that problem. We have that problem a lot too. The process that's using the file is VS.NET itself. This mostly happens when you debug an app, but happens sometimes when simply building files. This is a problem both in VS.NET 2002 and 2003. The only way to fix the problem is to restart VS.NET (devenv.exe). When you're not having this open file handle problem, the solution I posted before should work well; it's also mentioned somewhere in the VS.NET product documentation, but I've been unable to find that or the step required to automatically see UserControls in the toolbox (which was arduous in VS.NET 2002).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
Ahh yes, that problem. We have that problem a lot too.
Good to know I'm not alone. That problem seems to be fixed (temporarily?) if I change the output path for the assemblies in question. I've also been able to get around it by restarting VS (like you mentioned), but rebuilding the solution would often cause these files to be reported "in use" by VS. Hopefully Whidbey will address this.
And whaddya know, that did the trick - soon as the "file in use" errors go away and a solution rebuild works completely, projectB sees projectA's updates.
As always, thanks Heath for your help (and speedy responses, 2 quick replies and a a resolution to my problem within 5 minutes. A new record! )
The graveyards are filled with indispensible men.
|
|
|
|
|
I want to run my application run in win98 and it use MS ACCESS. Should I need to istall MDAC seprately there or required filed is part of .net framework?
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
MDAC 2.6 or higher is required to use ADO.NET. MDAC 2.7 or higher is recommended, though I think most of the features that require 2.7 is for the SqlClient. You can download this and include it as a Custom Action in your installer project from http://www.microsoft.com/data[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Salam, you can also download the MDAC merge module from, as I remember, Installshield web site[^]. Then include it in your project.
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
Thanks Maysam.
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
I am used to Java programming for quiet some time now, and I was used to be able to add whatever component I could come up with within my popup menues (A ComboBox or a TreeView for example). But somehow I cant figure out how to do that in C#!
Does anybody know how to do this?
|
|
|
|
|
In .NET, almost every control (and many other classes) actually encapsulate native resources (like HMENU s in this case, and the related APIs) unlike in Java (although frames and othe controls are still tied to HWND s, which is accessible via JNI).
Since this is possible using the Win32 APIs, it is also possible - though not always easy - in .NET (on that note, .NET 2.0 will apparently have a new WinBar class and derivative classes that will make this MUCH easier, but it's still pretty raw when I tried it from the PDC build).
I tried a quick search on CodeGuru[^] (has lots of custom controls like this) but couldn't pinpoint something specific. I'm sure you'll find some information there, though I'm betting it'll be in VC++/MFC. The same practices can be applied to your derivative ContextMenu through the Handle property (gets the HMENU you can use in native function calls).
Also, I did manage to find one example that is free for non-profit applications at http://www.divil.co.uk/net/controls/sandbar/[^]. There are several other commercial implementations that would do much the same thing (or that just define their own ContenxtMenu -like components from scratch without using native resources) such as http://www.infragistics.com[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am using VisualStudio.NET 2002 with .NET Framework 1.0 Actually i am developing a program in which i have to use Browser Control. I have used it on a control which facilitate me in providing wizard. Actually it is a wizard control on which i have used WebBrowser Control. Now i have start it both bu using Debug and without debu it is alright. Now i have created a form in which i call this wizard. Now if i run this program without using debug it will run alright but if i run it with start using debug it will give me error that cannot instantiate Active X control. What can be the problem please guide me
ThanX in advance
Regards
INAM
Inam
|
|
|
|
|
The browser control, while incorporated as a .NET control, is just a wrapper for the COM-intense MSHTML object. You should check the properties of your project to ensure you have the following properties set:
Under Debugging: Enable Unmanaged Debugging
You may still have problems if you do not have the symbols installed for the OS....just a heads up.
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|
Sir
Thanks for ur reply Sir but i want to know that from where i can change my properties of Debugging to Enable Managed Debugging and How can i check that if i have the symbols installed or not. and if they are not how can i installed them. I will be thankful to u for giving me time
Regards
minamkhan
Inam
|
|
|
|
|
Inam wrote:
where i can change my properties of Debugging to Enable Managed Debugging
Inam wrote:
This falls under the topic of 'basic things you should know before you begin to think about writing code'.
Pull up the properties for each project in your solution that is using unmanaged code.
Go to Configuration Properties Tab, Debugging.
Set Enable Unmanaged Debugging to true.
How can i check that if i have the symbols installed
Well, for the OS it is really dependant on whether you build your machine or if you have a managed desktop. For the former - you used to be able to select install symbols during the install process. For the latter -- you probably do not have symbols installed. Also, you need to reinstall symbols for the OS with each service pack and hot fix. Check MSDN or the main Windows website for installing the symbols. You should also be able to get the symbols from the Win32 SDK.\
The obvious tell tale sign that you do not have symbols installed is if the unmanaged code craps out, and VS says 'An exception occured within unmanaged code, but no symbols were installed....'
_____________________________________________
|
|
|
|
|
I have set the Enable unmanaged debugging to true but the same error comes .
Actuallt the error when catch through exception is
"
System.Threading.ThreadStateException could not instantiate ActiveX control 'GUID of Control ' because the current thread is not in a single threded appartment at System.windows.Forms.AxHost ctor(String clsId,Int32 flags).
"
Thanx in advance
Regards
minamkhan
Inam
|
|
|
|
|
Make certain that you are using the .NET wrapper that is in the design toolbox and not doing your own ActiveX control.
You have a Win32 form which (as the exception states) is apartment threaded. Unless you use specific thread types that are apartment-aware, then you will get that exception. It sounds like the control on your form is trying to start a thread of its' own which is a no-no in a Winform.
This really goes beyond COM, unmanaged debugging, etc. as it is the implementation of the control, not the actual execution of the unmanaged code.
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|
I will explain the scenario
I am updating database with dataadapter method at the same time if some person is attempting for the same thing...How do i will get to know abt this?
Praveen
|
|
|
|
|
If you need more sophisticated algorithm for updating database change you application architecture.
And/or u can use SELECT FOR UPDATE SQL construct. But with this method selected rows will be locked for other users to update or delete.
Tomas Rampas
------------------------------
Systems analyst, MCSD
|
|
|
|