We use C# form applications as HMI for our Automation projects. While doing this we generally use button click events. These events are changed boolean values from false to true. My problem starts here. There are lots of boolean and if I add button events one by one, I will spend many many times. So I want to do my own button component and. I will drag and drop my button from toolbox and relate it with a boolean using properties window. After doing this, It will do everything automaticly instead of me. Button design is not important for me.
Example:
//Define Variables
public class PLCVars
{
public bool PLCVar1;
public bool PLCVar2;
public bool PLCVar3;
public bool PLCVar4;
public bool PLCVar5;
public bool PLCVar6;
public bool PLCVar7;
public bool PLCVar8;
}
//(!)I have a PLCVars object defined as PLCVariables
//Button Events
private void button_JogPLCVar1_MouseDown(object sender, MouseEventArgs e)
{
PLCVariables.PLCVar1 = true;
}
private void button_JogPLCVar1_MouseUp(object sender, MouseEventArgs e
{
PLCVariables.PLCVar1 = false;
}
As shown above example, I want to relate my button component with a plc variable. It will make all mouseup and mousedown events automaticly and change the value of plc variables.
As I searched, I should use Custom Control. But I don't know relating form variables with Custom Control components is posibble. If it is possible how?


bool x = false;? How you add events to boolean? Show us this code. relate it with a boolean using properties window - what does it mean? How you relate button with boolean? - Sergey Berezovskiy