xarial / xcad

Framework for developing CAD applications for SOLIDWORKS, including add-ins, stand-alone applications, macro features, property manager pages, etc.
https://xcad.net
MIT License
126 stars 25 forks source link

How to order Custom Property page content #82

Open flycast opened 2 years ago

flycast commented 2 years ago

Seems I can't make my controls order in the order I want. I see the Attribute: [Order(1000)] That does not seem to have an effect. I have tried this from 1 (first) to 1000 (last) and from 1000 (highest displays first) to 0 (lowest displays last). Neither way seems to make any change.

Code looks like this:

{
    [ComVisible(true)]
    [Title("Dispense File Options")]
    public class OptionsPageData : SwPropertyManagerPageHandler
    {
        [Title("Make Dispense File")]
        [ControlTag(nameof(DispenseFile))]
        [Order(1000)]
        public bool DispenseFile { get; set; }

        [Order(3)]
        [Title("Units")] public Units Units { get; set; }

        [DependentOn(typeof(EnableDepHandler), nameof(DispenseFile))]
        [Order(2)]
        [Title("Total file dispense volume")] public double Volume { get; set; }

        [Order(200)]
        [Title("Application Settings")] public AppSettings AppSettings { get; set; }

        [Title("Dispense Style")]
        [ExcludeControl]
        public DispenseStyle DispenseStyle { get; set; }
    }
}

Result of code looks like this:

image

artem1t commented 2 years ago

Thank you for the question and sorry for the delay in the answering the question. Unfortunately, SOLIDWORKS seems to prevent mixing groups and controls when ordering, i.e. you cannot put control, then group, then control. It will always firstly list groups followed by controls.

In your example, it firstly put Units group as it has order 3 followed by App Settings group (order 200).

Then it placed all controls where first is number box (order 2) followed by check box (order 1000).

I recommend placing all controls within the groups so you can properly order.