I would like to let users resize my form but when they reach a specific size to disable this ability to make it smaller window than i want.
Any suggestions?
You can set the MinimumSize property of the form to the minimum size you want to enforce.
There is also a mirror property MaximumSize (mentioned for completeness).
Set the MinimumSize property on your form. This will prevent the user from making the form any smaller than this value. Similarly, you can set the MaximumSize property to ensure that they cannot make it any larger than that value.
Set the form's MinimumSize property in the designer.
Set the form's MinimumSize property to the smallest size you want to allow.
Related
I seek to change the default setting of a .NET Windows Forms control's property, without creating a custom control inheriting from it.
What I want is, for example, to add a TextBox on my Form that already has the TextAlign property set to HorizontalAlignment.Right instead of HorizontalAlignment.Left. Even if only solution-wide, if achievable, I would love to know. This would save a lot of time for when one is working with a LOT of controls and needs to set their properties to specific, non-default, values.
Creating a custom control is just too overkill for this, and would clutter my solution with unnecessary things. I have also considered running a regex on the designer files solution-wide (to add the non-default values to such controls), but writing regex like that can (also) be time consuming/problematic.
Any ideas?
There is a way to do that. But you need to set the binding initially. Later on you can set in one go to all the controls of your choice. This might be not your exact answer but this is how we define styles like as in WPF
(1) Click the Application Property Bindings
(2) Define Binding
(3)Now for textbox you can set the initial default
(4) Now You can set the property binding of every textbox intially or you can code which will set the application settings at starup or on form load.
This will you help to change the default propety at once later on
I have ADF application, which is a film database. I have a big problem with settings ADF component af:inputText.
I tried a lot of different width settings of the various components, but I always failed.
There are pictures...
You do not know how to do it please? Thank you.
Set the contentStyle
Example: contentStyle="width:240px;"
(Setting inlineStyle only adds CSS to the wrapper span - which is an inline style, so cannot set a width.)
It's also worth setting simple="true" to remove other styling emitted by the control.
If you are using ADF BC then by default the width will be the number of character in your database, for instance if you have VARCHAR2(255) then your text box will have 255 columns.
2 Ways you can solve this:
From the Entity Object, Select an Attribute and in UI Hints and change the width to suite the number of characters you want - 70 seems good width.
From the page itself, change columns attribute of inputText to whatever you want - Still 70 should look ok
You don't give the data source, but assuming it is coming from a VO via a Data Control,
Find the VO that is the basis for it, and select the attribute and change its display width property in the UI hints area.
If not a VO, then indicate the source of the data for further help.
i think width / height of input components can be set using CSS as well. you can try setting content style property to value something like :
width:100px; height:15px;
By default, width will come through EL expressions from width values set as UI hints for ADF BC objects.
you can edit input text component size / appearance using rows / columns properties as well.
Possible solution is to change the number of Columns.
Select the TextBox you wan to change its width.
Go to the Property Inspector
Under Appearance, Change the Columns property based on what is good for you.
hope That's help you
Go to the Entity Object
Select attribute, give the DisplayWidth What you want
Later give contentStyle="width:240px;"
Try using Panel Grid Layout as shown
Select the TextBox you want to change its width.
I have this TextBox that has a MaxHeight value of 62 by default in my XAML file, and I want to programmatically unset it from codebehind on a certain event. Sadly, this:
myTextBox.MaxHeight = 0;
actually sets the maximum height to zero... making it invisible. Isn't there a method on UI elements to purely unset a specific property?
There is a method to reset any dependency property to its default value, without explicitly specifying (or even knowing) the value. Just call ClearValue:
myTextBox.ClearValue(FrameworkElement.MaxHeightProperty);
Note however that this clears the local value of the property. If there is any value set by a Template or Style Setter, that value will be effective then.
You can set it back to it's default value:
myTextBox.MaxHeight = double.PositiveInfinity;
This allows the text box to grow to "any height".
I want to save form position. I have successfully set Form.Location property in ApplicationSettings->PropertyBinding but Form.Size is not listed in property binding list. Why? Do I need to add this property to save properties list using code?
The Form class overrides the Size property to prevent it from getting saved. This is by design, it uses the ClientSize instead so that the size doesn't depend on the border width chosen by the user. You'll find ClientSize in the property binding list.
This is still not a good idea, you don't want to save the size if the window is minimized or maximized. It will not restore properly. Instead, override the OnResizeEnd() method and only save the size if the WindowState is Normal.
I have a childwindow with a number of Textboxes, Comboboxes, and DatePickers. I want to know if a user has changed any value in these (to know if I need to save to db)
One way I could think of doing this are in the 'on chg' event handlers and set bool. But if a user changes the value, in say a combobox, then changes back to the original this would still be seen as a change.
Are there other alternatives?
(note the project is not set up as MVVM)
If you don't use mvvm but still bind to an object then:
before the window is shown create a copy of the object, save it, and bind it to DataContext
whenever you need to know if user made any changes you can compare the saved object to DataContext (property by property)
I you don't use binding at all then:
before the window is shown save all fields that can be modified to a Dictionary
whenever you need to know if user made any changes you can compare the dictionary values to values of the fields