Checkbox indeterminate for checkbox groupbox - c#

I have a groupbox of checkboxes, I want to link the groupbox with Themes checkboxThemes image is an example.
How to link Theme1 and Theme2 with Themes?

You gave no indication what 'linking Themes to the groupbox' means nor what the indeterminate state means. However, since checking/selecting Theme1 probably excludes the use of Theme2, it seems like you are not using the right UI presentation (since the user can select both).
Consider a ComboBox with the Entries {"No Theme", "Theme 1", "Theme 2"}. That way no one is confused and less form space is consumed.
Edit
If your edit really reflects what you want, set the "outside" check state whenever one of the inside checkbox's checkstate changes. It still makes no sense - what do you do when the user checks/unchecks the outside box?

Related

In a property grid is there a way to unselect all grid elements programatically?

I am working on a project in which I am using a property grid to display the properties of the selected control.
The Property Grid is fixed to the left edge of the container and in the rest of the space I have the form I am designing.
On clicking a control on the form, the specific control’s property is getting selected.
In the above figure, I have selected the textbox and the textbox’s properties get shown on the propertygrid.
Here if you observe, by default, the Name property is highlighted as well.
Is there some way to unselect this property programmatically?
I have tried some suggestions online but none have helped. I am not able to find find a way to remove all selections from the PropertyGrid, but its behaviour seem to be different form a DataGrid...
Here is why I need this...
On selecting a control, if a property in the property grid is selected, then the property is getting modified.
For example, If i cut the control using Ctrl + X, the selected value in property grid is getting cut which in some cases is forcing user to set the property before modifying anything on the form.
I have tried selecting multiple controls, but in that case alse the selected property seems to be persistent
Since PropertyGrid uses DefaultProperty to select a property in its grid, as an option you can set DefaultProperty attribute at run-time for your object to a non-browsable property, for example:
this.propertyGrid1.SelectedObject = null;
TypeDescriptor.AddAttributes(someControl,
new Attribute[] { new DefaultPropertyAttribute("Site") });
this.propertyGrid1.SelectedObject = someControl;
Well, what you are trying are hacks. It is never a good idea to do such hacks particularly if you are not the only person that use the software.
In your case, the focus should be on the designer while you interact with it. So if the user press Ctrl+X, the designer should respond to the keyboard and it should not have any effect on the property grid (as only one control can have the focus at the same time).
Thus it is up to you to make sure that your designer is focusable, that it has the focus when initially displayed, that it get the focus when you press the TAB key. Pressing the TAB key again should put the focus on the property grid so that user can interact with the grid without using the keyboard.
If you have more than these 2 controls, then obviously TAB should also stop at any appropriate controls. Also, it can be a good idea to have some direct shortcuts like F4 to (show and) activate the properties pane.
If you are not able to make it works, then the best compromise would be to use another windows for the properties grid. By using a distinct Tool windows for the properties, it should not respond to the keyboard when the main windows has the focus.
Here are some links that might help you:
Panel not getting focus
Control.Focus Method() — See Remarks section.
In any case, you should not prevent Ctrl+X to works as expected when the property grid has the focus and a property is selected. Users don't like software that do not follows UI conventions.
As a software developer, you should as much as possible ensure that your application follows standard behaviors. I recommend you that you take one or 2 extra days developing your software properly instead of doing hacks.
Often, compromise to gain a few days will never be fix and will be a pain for many years. Better to do it right from the start. Unselecting an item in the property grid is not an acceptable workaround. Your manager should not allows you to do that.

what does it mean by the state "Indeterminate"

when It comes to checkboxes there is a third state called "Indeterminate", what does it mean?
what other controls have this "Indeterminate" state?
thanks
From CheckBox.CheckState property
Indeterminate
The CheckBox displays a check mark and is shaded.
The control appears flat.
Here a nice virtualization of what is exactly mean..
Here a demonstration with Javascript.
Shameless copy and paste from Wikipedia:
Some applications use checkboxes that allow an indeterminate state in
addition to the two provided by a normal checkbox. This third state is
shown as a square or dash in the checkbox, and indicates that its
state is neither checked nor unchecked. This is most often used when
the checkbox is tied to a collection of items in mixed states. The
indeterminate state cannot usually be selected by the user, and
switches to a checked state when activated.
For example, a checkbox presented to select files to send via FTP
might use a tree view so that files can be selected one at a time, or
by folder. If only some of the files in a folder are selected, then
the checkbox for that folder would be indeterminate. Clicking on this
indeterminate checkbox would select all or, less commonly, none of the
contained files. Continuing to click on the checkbox would alternate
between checked (all sub-directories and files selected) and unchecked
(no sub-directories or files selected).
Some tri-state checkbox implementations allow the user to toggle among
all states, including the indeterminate state, by remembering the
mixed state of the items in the collection. This serves as an undo
feature.
In the case of a CheckBox, indeterminate could be used to indicate a "we don't know yet" kind of answer when a true/false situation is present.
Indeterminate can also be used in cases where multiple selection is involved and some items in the list are true, but others false.
Cheers
On binding checkbox if property value is null than checkbox show indetermine state.

SemanticZoom: is it possible to stop the view transition in code behind?

I have a grouped gridview inside my "zoomed in" part of the semanticView control. Groups can be empty (I used ).
In my "zoomed out" gridview I have listed all letters from "A" to "Z". Letters referring to empty groups appears disabled (dimmed Foreground, there isn't a "IsEnabled" property available here).
What I need to do is abort the "zoom in" transition in response to a click on a letter corresponding to an empty Group.
Any suggestion?
Thanks for your time.
Orf Quarenghi
I'm not 100% sure of this answer as I currently have no way to check/test - but as a suggestion I would check if IsEnabled property disables the semantic zoom transition from firing.
You mentioned there isn't an 'IsEnabled' property - what are you checking? If you use a datatemplate to render your UI in the gridview you could use something like a Border (which does have IsEnabled) to wrap your Child/Item UI and bind the 'IsEnabled' property to the respective field on whatever you have placed in your ItemSource.

how to display checkbox inside richtextbox for acceptance of Terms and Conditions

I am working on window application. I have a form where I will be displaying terms and conditions against shopping done. Below Terms and Conditions, I want to show Checkbox which user have to check as an acceptance before proceeding.
This Checkbox should come below the terms and conditions. If terms and conditions are long enough then user have to scroll down to make sure he has gone through all the agreement. Only after which he can check.
I was thinking to do it with rich textbox. Is it possible to do with any way.
Use scrollbar events to determine when user scrolled whole text and then set checkbox visible. In that case checkbox can be initialy posiotioned outside rich text box ( ex. below).
Don't.
Concerning new users, the checkbox will stay unnoticed by most users, and things will be really confusing when the user will, on submit, see the message saying she didn't check the checkbox, but there will be no visible checkbox in the form. Since there are no existing forms which use such thing, few people will be able to guess it, so some users will just abandon the process, and other will go submit a bug, telling you that the checkbox is missing.
Concerning old users, they don't and won't need to read Terms and Conditions every time, so putting the checkbox at the end creates excise, but brings nothing at all to compensate it.
But you can. Now, technically, you can use a scrollbar, then put in the scrollable area a richedit (with no inner scroll) and a checkbox below. I don't think there is a way to put the checkbox inside the richedit.
use a panel to hold the richTextbox and the checkbox.
set
Panel.AutoSize=false;
Panel.AutoScroll=true;
richTextbox.Dock=DockStyle.Top;
richTextbox.ScrollBars=RichTextBoxScrollBars.None;
richTextbox.Height=richTextbox.lines.length*20;
checkBox.Dock=DockStyle.Bottom;
EDIT
To make checkBox always follows the richTextbox, add following code after:
checkBox.Dock=DockStyle.None;
checkBox.Location=new Point(checkBox.Location.X, richTextbox.Height+richText.box.Location.Y);

highlight selected item in flowlayoutpanel

how do i highlight the selected item (in my case, a custom user control) in a flowlayoutpanel
FlowLayoutPanel is purely for layout - it has no concept of a "selected item". You might be able to add some logic to your UserControl which changes its colour when it receives focus (and changes back when it loses focus) but that would be independent of the layout control that's hosting it.
I created a Bindable FlowLayoutPanel that included setting the selected index (with highlighting depending on the selected control. I posted it over on the code review site. Check it out and let me know if that works for you.
Check this implementation, Through event handling

Categories

Resources