Author Topic: what is the best way to make new user control with few advance hmi controls in i  (Read 1310 times)

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
hello

what am trying to make
is new user control
that has a basic button and two image display by value

and then i use it in my interface

what i do is that i add new item
UserControl1.vb

then i add the button and the images
so it automatically it add comdriver
i remove it
but each time i try to use it in the main form i face multy problems

what i need
is to make it
with properties
so from the main form i can choose
1- the plc address for each one ( the button , the two image display by value )
2 - the text
3- the com driver
4- the images for each imagdisplaybyevalue control


i hope that someone can help me

with thanks



Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
The best way is probably NOT to create one because it's quite complex and a bit pointless since these 3 controls can be easily dropped from the toolbar and all their properties can be accessed.

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
The reason is am gonna put over than 50 of them in my project and it is easier to make them as one control

Phrog30

  • Guest
If I was going to use several I would make a control as well, that's just smart programming. I don't think it's complex. What errors and problems did you encounter?

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
I will give you some time to realize how pointless it is to create a control like this.

Just for a comparison, I would put a GroupBox on the form and add those 3 mentioned controls to it.
In the Designer, all these can be sized and positioned any way one could desire.
All the properties would be available and I could go about copying and then pasting this GroupBox 50 times if necessary (still preserving the availability of all the properties).

And, for educational purposes, I did bother creating this control so all the members can see one possible way of creating a control that has multiple AHMI controls in it and is exposing all the properties. In the Designer, AHMI controls do have to be sized/positioned manually through properties (if desired).
In order to add any other AHMI control, one would have to follow the pattern in the code and know the layout.

Attached are 2 flavors of the control, Control style which is borderless and Panel style which offers a border (UserControl style was slightly misbehaving and was avoided).

My choice would still be the GroupBox example.
« Last Edit: June 17, 2018, 06:08:48 AM by Godra »

Phrog30

  • Guest
Anyone that does a good amount of work in scada/HMI, whether Wonderware, FT, Ignition, etc., would very much disagree with you saying it's pointless. It's about ease of deployment and maintainability. I create reusable graphics the majority of the time.

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
I will not disagree with you but just say this:

The GroupBox example is suitable for all users of AdvancedHMI while creating a control is not.
Vast majority of the users will have a hard time understanding the code regardless of how it's created.

The GroupBox example can use any AHMI control while the created custom control always has to be modified to accommodate that (which can be done only by those who understand the code).

Any time and effort invested in either creating or modifying this kind of controls cannot be easily justified since using the GroupBox beats it at anytime.

Feel free to offer a better approach to this, something suitable for most users.

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
thanks guys for your response
i already used panels and copy and paste before i asked about the best way

but i needed a better way more user friendly like in my question

:)




Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
If you can understand the code in either of the controls posted previously then you can modify it to suit your purpose.