I have some DomainUpDown controls in my application. The behaviour is set like this:
Normal: Each control can individually goes Up/Down (Change selected item)
Special: If a check box is checked, Up/Downing the first control will cause the other controls to change as well
Now there are some cases that I want some of the controls to be disabled by setting Disabled = true. I did it, but in this case changing the selected item of the first control will cause the other disabled controls to change the selected item as well.
Is there a way to completly disable a control so it does not accepts something like control.Text = "bla bla" ?
P.S: I need not to hide the control!
One way:
You can hold a list of Textbox.Text values, which will hold entries for all of your textboxes.
Upon OnTextChanged:
if your textbox is enabled - update it's text property and store it up in the list.
if your textbox is disabled - set it's text property to the last value you had in your list.
You can use a Dictionary or anything similar that contain KeyValuePair objects.
I'm afraid there's not. At least not without additional work.
Related
i used PropertyGrid control to display properties on gridview.
i have taken an reference of this link http://www.c-sharpcorner.com/article/using-property-grid-in-c-sharp/
which is showing like this
But i need checkbox just before the property name shown in red mark on check/uncheck for any property i need to build expression.
I recommend reading this: How do I change boolean properties with one click in PropertyGrid.
It extends the PropertyGrid control and defines its checkbox controls using UITypeEditor.
As Reza mentioned, your choice of control does not appear optimal. You should probably create a form with TextBox, CheckBox, ComboBox etc. Or make use of DataGridView if your display is catering for multiple records at same time.
If you most definitely want to customize PropertyGrid, here is my another answer which might help you start with.
Linked answer:
You can make use of TrackBar. Note that PropertyGrid by default does
not allow you to add controls like these to it. So, you will need to
do some work here. You will need to create a class that inherits from
System.Drawing.Design.UITypeEditor. Next you will have to set the
editor attribute for the property that has to display track bar as
control. Note that unless you do custom paint, it will be shown as
modal dialog or as dropdown editor.
Is it possible to make a ListBox ReadOnly? - Technically yes. Set the "Enabled" property to False.
Selection: None break my program because it's trying to select them from the program, but if a user selects one, I don't want it to change, or highlight. I want all highlighting done by the program, is this possible?
This picture shows what I have on my Form
My problem is, it works perfectly fine, I just want it nicer, by only allowing the user to click on only one of the selections from the red box, while they cannot select one from the blue boxes, but the computer can.
My assumption is that you are using WinForms, not WPF. So a simple way is to add a bool flag for each list control to your form. Then on the Selection changed event prevent the change from occurring unless you've set the bool to true. That will allow you turn on/off selected item changes.
Actually here is a link here, instead of bool just create an int to store the current index for each list box. Upon the Selection changing simply set the SelectedItemIndex to the int variable.
Cancelling ListBox SelectedIndexChange Event
How to disable editing or hide text edit field, when DropDownStyle = Simple for Combo Box control?
MSDN on ComboBox.DropDownStyle:
The DropDownStyle property specifies whether the list is always displayed or whether the list is displayed in a drop-down. The DropDownStyle property also specifies whether the text portion can be edited.
Docs on ComboBoxStyle.Simple:
Specifies that the list is always visible and that the text portion is editable. This means that the user can enter a new value and is not limited to selecting an existing value in the list.
So, ComboBoxStyle.Simple suggests that list can be edited by user and it's confusing to disable edit with this DropDownStyle selected. Alternatives:
If you are ok with drop-down list use ComboBoxStyle.DropDownList
If you want to display a non-editable list with a view similar to ComboBoxStyle.Simple consider using ListBox
If you really need to achieve this effect on Combox you can just catch the events like "TextChanged" and then setting it back to "" and asking if (!comboBox1.DropDownStyle == ComboBoxStyle.Simple) before adding items to Items collection. Although it seems there are better ways to achive similar functionality using listbox as suggested before.
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.
I have 2 grids. When user is doing edits in one grid, I want to disable the other grid from getting focus, or atleast other grid from changing its foccussed row.
Example:
Parent grid, children grid.
If user is making edit in children of particular parent. I want to prevent user from suddenly shifting focus to different parent row. how to do that ?
The only ways you can prevent a control receiving focus is to change it's Enabled or Visible properties.
Simply changing the parent's Enabled property to "false" (e.g. for the CellBeginEdit) and then back to "true" (e.g. in the CellEndEdit event) will prevent the user from selecting a new parent row.
There are a lot of ways to do this but thats how I would do it (just a concept so ignore if any property does not match):
Create a property called mode and then use enumeration to set it to Edit or None etc.
Suppose you have GridViewParent and GridViewChild. In the FocusedRow event of child grid, at the start of all code, set the value of mode to Edit and at the end of all code in the event set it to None.
Then in the FocusedRow event of parent grid check whether the mode value is edit or not, if it is edit then use e.Cancel or something to get out of the focused event of the parent.
Now if you let me know exactly which grid are you using I might send you the code.