2
Answers

User Controls

Photo of Shr0ud

Shr0ud

21y
1.6k
1
I have developed a user control that represent a line in a manufacturing facility, it uses drag n drop and works very well at its job, what I'm having trouble with is getting the data that exists in the controls UP to the main program, I have tried the following with little success.. for(int i = 0; i < this.Controls.Count; i++) Scheduler.Line myLine = Scheduler.Line(this.Controls[i]); or Scheduler.Line myLine = this.Controls[i]; and a few other variations, when in debug I can read all the data properly as it knows the control is of type Scheuler.Line. I just want to know how I can pull it back into the main program. Regards Paul

Answers (2)

0
Photo of Shr0ud
NA 6 0 21y
Unfortunately this method doesnt work as the compiler throws up an error... but I have found a way around it with re-designed structure. It is the assembly type line
0
Photo of spgilmore
NA 591 0 21y
This is a strange post. Your question asks "how to get the data out of a cotnrol and into the main program", but your code seems to be attempting something different. It almost seems to ask "how do I check for the type of an object?" What kind of data is this? It should probably be exposed as a public property, but the data type will depend on what kind of data you are working with. When you say "Line", I think of an assembly line which may have any number of attributes (properties) that you're storing, or a graphics line, which has 4 integer cordinates and maybe a color. Data that is internal to an object should be exposed through public functions or properties. In order to check for the type of an object or one of its ancestor types, you can use the IS operator. Maybe something like this: for (int i = 0; i < this.Controls.Count; i++) { if (this.Controls[i] is Scheduler.Line) { Scheduler.Line myLine = this.Controls[i]; break; } }