One of the frustrations with the standard TreeView is that you can't show a partial selection to indicate that some of the children are selected. A partial selection in a complex tree allows the user to easily determine where the selections are, even if the tree is not completely expanded. A similar idea is used in manu backup programs to allow the user to select the files to be backed up.
Does anyone know of a way to make the checks in a treeview checkbox gray? I want to gray the check of a parent node when some (but not all) of its child nodes are checked. Kinda like what you see when you are selecting options to install during a software installation.
I have seen several post, but is older (2000, 2007 year).
I now, in 2010, the better answer possible is required. I use VS 2008 . Net 3.5 , Windows Forms
I am using this Tri-State TreeView, also from CodeProject. Works just fine - should you need a project more up to date.
There's a nice article on code project about just this. Tri-State TreeView Control
Related
I have a C#.NET winforms project, and some controls are moving in design view whenever I build the project. Its only some of the controls (a panel with a label and datagridview in it, a button, a link button and a label) are all moving up on each build.
Has anyone seen this before or know how to fix it?
I think it is because of the AutoScaleDimensions. My guess is that your form was originally created on another machine.
Per MSDN.
"The AutoScaleDimensions property represents the DPI or font setting
of the screen that the control was scaled to or designed for.
Specifically, at design time this property will be set by the Windows
Forms designer to the value your monitor is currently using. Then,
when the form loads at run time, if the CurrentAutoScaleDimensions
property is different from the AutoScaleDimensions, the
PerformAutoScale method will be called to perform scaling of the
control and all of its children. Afterwards, AutoScaleDimensions will
be updated to reflect the new scaling size."
My guess is that for odd some reason when you build you project property (maybe some others) gets adjusted, but not on design time.
I think about few possible reasons:
You work on multiple monitors and/or there is some odd stuff with your adapter.
There is some problem with auto-generated designer file. Maybe it
edited manually somehow.
To fix I propose to do something I would do:
Recreate form from scratch if possible, by copy-pasting bits
one-by-one.
If not take some merging tool and insert fresh form
properties.
Also here is another interesting question on AutoScaleDimentions.
I've created a series of usercontrols. Dragged one of the controls to the main form. It shows OK. Went back and made a change to the design of the user control. Rebuilt project. Cleaned project. manually removed all project binaries including the obj folder. Change still doesn't show on the usercontrol hosted on the main form. Dragging a new instance of the control from the tool box only shows the old version of the control.
Completely removed the controls from the toolbox and adding them again fixed the problem, but surely I don't have to do this everytime I make a change? All user controls are in the same assembly as the main form. Tool>Options>Windows Forms Designer>Auto toolbox Populate is set to true. Any ideas most appreciated. Thx
Do not add the control to the toolbox yourself. This puts a copy of the assembly in a private directory. Yes, this copy does not get updated automatically, you get the old control.
Rely on the "Auto toolbox populate" setting. It automatically adds any controls you have in your loaded project(s) to the toolbox. The added controls are at the top of the toolbox.
I agree with answer 1 that that is what is supposed to happen, and often does. But it doesn't always work and will work partially sometimes.
For example my current Solution.
Project 1 namespace ToolsTester - This is just a temporary form to test the view tools in the 2nd project.
Project 2 namespace UltimateFileFinder - This has three views.
The first 2 views (user controls) UltFilesView and UltSlideShow appeared as usual on the toolbar so I could drag them onto ToolsTester to try them out.
Then I added another user control UltPanel, this will not go onto the toolbox. Though it compiles without errors.
I have come across this problem a few times, sometimes removing and reasserting the reference fixes it. Other times I would have to remove the test project and create a new one.
I tested Visual Studio (full version) before release and this was one of the areas I reported back, so the problem was known pre-release.
This project I am on now I know that I will need to remove the test project and create a new one, in this case the tester is only a few simple caller and event responses, that is not always the case, there are times when the tester project can be quite complex because it is mimicing the target that the tools will be part of.
I'm using winforms. I spend a lot of time drawing forms (maybe not a lot, but it is a boring task).
To sum up... I want to develop a simple aplication that connect to a sql server database, let the user to select a table, and put the controls in a form for me (generate the designer code), based on the tipe of each column. Then my app will name each control like the column of the table, set the maxlengh property (if the type is varchar), and create a label with the same text near the control. If the column is a FK, then the app will draw a combobox and so on. I saw that Telerik Open ORM make something like this, but I only need a simple app for the IU Generation.
If the same day I finish my little application I discover a tool that make the same... I will feel myself stupid :D
Are there any tool out there that do this work for me?
You can just drag DB columns from the Server Panel and drop them on the Form. This will generate TextField, CheckBoxes and other UI elements for you.
You can also drag the entire table and drop it on the form. Same thing will happen: all fields will get generated.
This is using plan Visual Studio 2008 IDE.
Take a look at DevExpress - they have a number of ways to do exactly this. (We're a happy user of their product.)
Take a look at Microsoft lightswitch. I had posted a similar question as yours and stumbled upon it by accident. Devexpress also has an orm like Teleriks http://www.devexpress.com/Products/Index/Frameworks.xml. I am using Lightswitch for form gen. good luck
The first time I try to open a particular form many of the controls (those with anchors on the right side and/or the bottom) are shifted and my grids automatically regain all the columns from their datasource which (the columns) I had previously removed.
I have read elsewhere it is recommended to copy the 'good' designer code into the constructor after the InitializeComponent method. This doesn't seem to be a good long term solution, eg what if a user makes future design changes?
Any suggestions/workarounds? Is this a Visual Studio 2008 bug?
I found deleting the controls and adding them back in works. Not just cut and paste, but adding the controls back from scratch. This seems to be related to where to designer code is written in the InitialiseComponent method.
This link describes some issues with anchoring and derived forms:
http://weblogs.asp.net/rweigelt/archive/2003/09/24/28984.aspx
Visual Studio 2008 does a much better job of detecting and adding controls from projects to the toolbox for use in the forms designer. If you have an assembly with a UserControl- or DataSet-derived type, then it will automatically detect and add that control to the toolbox for designing forms. This is slightly better than the old system in 2005 that made you manually add controls and would occasionally forget them, etc.
However, on the legacy, monolithic project I am working on (now upgraded to vs2008) this means many controls that I don't want and don't need (and a redesign would not be warranted against so much legacy code :( ). I imagine that if I made certain types internal or private, then they wouldn't show up. However, I need many of those to remain public, but not show up in the toolbox. Furthermore, with so many controls getting added to the toolbox, opening the winforms designer slows significantly.
Is there an attribute or other mechanism that prevents toolbox appearance (that wouldn't otherwise affect functionality) ?
Would filtering using such a mechanism improve performance while still autodetecting new types that SHOULD be in the toolbox? (I know you can disable the autodetect, but its nice to have in many cases)
Have others encountered this irritation on large solutions (with many csproj/vbproj files)?
Edit: Thanks everyone! I knew it had to be simple (and was likely an attribute) but that fills the gap. Nice to know that I was in good company in not knowing about ToolBoxItem(false).
The following attribute should hide it from the toolbox:
[ToolboxItem(false)]
If you apply it to all the types you don't want to show, it will still show any new ones you create without this attribute. Note, you may have to manually remove the items to start with.
This blog post shows some other attributes you may want to use.
Go through the toolbox and for each custom control that you see that you want to hide, add the following attribute above the class:
[ToolboxItem(false)]
Of course, this is a compiled attribute and will affect everyone using the code, so I only recommend doing this for controls that don't make drag-drop sense. Otherwise, you will probably make someone that loves that control very very angry. :)