When I add a new Form in the Ide, it gets default properties, but I always use a different font and a different background color - winforms

Adding a new Form in the project creates a default form with default properties. I have to change them manually, but in all my project I have the same properties (font, background color, etc.).
Is there a way I can change the default Ide template for Forms?

Not using inheritance as Adrian recommended is a mistake. It is the right way to do it because you can in one fell swoop change every form in your app by editing the base form properties.
But you want to change the template. That's easy to do as well. Start a new scratch project with one Form and change the properties you want to have customized. Click File + Export Template. Select Item template, Next. Tick the form, Next. Next. Give it a good name and description and click Finish. You can now select that template whenever you create a new form.

Create your own form control that is derived from the base one and has all the properties set just like you want them, then you can use this one all over your project. Also changing something will be very easy since you'll have to do it only in one place.

Related

Reference retrieval of a ButtonGroup instance

I have created an instance of ButtonGroup and associated that to two RadioButtons. The RadioButtons are added to a Container and the Container added to a Form screen. When the "Back" button is pressed, I want to clear the ButtonGroup selection and reset certain variable instances.
I want to place the code in the ActionListener I have made for the "Back" function. My question is how to retrieve the reference of the ButtonGroup in order to clearSelection()?
Generally we recommend recreating the Form instead of caching it if you intend to "reset it" so I'd avoid this.
If you still want to go in this direction check out getButtonGroup() in RadioButton. You can also set a new group with the setter method.
You can use setUnselectAllowed(true) then invoke setSelected(false) on both buttons. Then restore default selection behavior using setUnselectAllowed(false).
While looking at animateLayout() method of ComponentSelector for another issue that I had, I realized that I may use this Class to obtain Component object references jQuery style elegantly. Very powerful and useful concept for codename one.
should adding or removing components trigger a repaint?

How to change properties in all Forms in VisualStudio Project?

I have project with 50+ form. And I want to change icon in all form, that all forms have the same icon. How Can I do it?
You can create a Form in your project and name it BaseForm. Then set properties like Icon for BaseForm. Then in all other forms, you can inherit BaseForm instead of Form.
This way, all forms which you didn't touch their Icon property will use the values which is set in BaseForm. So if you want a Form to have a different Icon than the BaseForm, it's enough to change the Icon property in that form explicitly.
You can also use this approach for other properties like Cursor which you mentioned in comments.

Creating new UI controls programmatically in visual c++

I have just started using visual studio c++ (2010) with windows forms, but have cannot for the life of me find out how to create new UI items in response to events. What I would want to happen is click a button, and have a new row, with a couple of text boxes and buttons appear, with onebutton to delete the row if I keep clicking, more rows will appear, named row0, row1 etcv. I looked at this page, (http://msdn.microsoft.com/en-us/library/aa984255(v=vs.71).aspx), about adding controls programmatically, but when I add a new text box inside a click event, the text box is only created inside the scope of the event (as expected!), but I want to be able to create it insde the newRow click event, but access it and . I thought of making a 'row' class, with row.text and row.deleteButton properties, and at each creation of a row, respective events will be created for button clicks and text edits.
Is there anyway to do this, ie a function that can be created that creates new objects by passing the required name?
The trick for this to work is that you need to have declarations outside of the event handler to keep track of the newly added UI components. In the link you've given the added TextBox is locally scoped within the event function, and this will be removed from the heap (i.e. memory) when the event is finished.
So one solution would be to add a list of UI components to your form, and then have the events add to or remove from this list of components. To get this solution working you possibly need to read up on lists of objects (or possibly dictionaries) and how to handle these.
Sorry for a rather general answer, but the question is also very broad... :)

DevExpress DateEdit Force user to use menu popup

I have a WinForms app that uses this control and I would like to prevent the user from typing in a date. We want to make them have to use the popup calendar to make the date selection.
I tried setting ReadOnly of course but that puts the whole control into the read only state.
Our version of DevExpress is: 9.1.9.0
You can accomplish this task using the RepositoryItemButtonEdit.TextEditStyle property.
Assign the DisableTextEditorvalue with this property. In this mode a button editor is displayed in its normal way. However, editing and selecting text is not allowed.
Code snippet:
dateEdit1.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;

Implement SlideGroup as part of Form [DevExpress]

I would like the Windows UI style SlideGroup on my WinForms page but dont want to go through the nonsense of having a document manager taking up my whole form. I simply want a few buttons at the top of my form and then a slideGroup at the bottom. On button press switch the slideview to the corresponding document.
As far as I know the SlideGroup is available only as a content container within WindowsUIView, which is a part of the DocumentManager component. Content containers can be easyly added in the related section of the WindowsUIView Designer. The SlideGroup component is not a Control itself, thus it is impossible to use SlideGroup without a DocumentManager.
Please also review the following: How to create SlideGroup container.
If you want to use the Windows UI buttons itself you can use the WindowsUIButtonsPanel control.

Resources