gbr
July 23rd, 2005, 10:00 AM
Hi,
I'd like to devide my data from the user interface. Hence, I passe a reference from my data to each control. In theory, if I change the data and redraw the control, it should be able to access the data (because there are no copies of this data variable) and redraw according to the data value.
In order to ******** my description I will go into details: The control which is added to the main form is a derived Panel, which has a data variable which contains the color of this Panel. The data is stored in a Color array and passed to the constructor of the panel
for( int i=0; i < color.Length; i++ )
{
ColorPanel pan = new ColorPanel( ref colors[i] )
this.Controls.Add( pan );
}
However the theory is not matching the practise. If I change one item of the colors array and redraw the main form, the color of the colorpanel is not changed. Of course, I overwrote the ColorPanel OnPaint method to set the particular background color. The trace output showed that the old color value is still existing...
So, how to pass a reference packed in an array in c#?
Thanks,
gbr
I'd like to devide my data from the user interface. Hence, I passe a reference from my data to each control. In theory, if I change the data and redraw the control, it should be able to access the data (because there are no copies of this data variable) and redraw according to the data value.
In order to ******** my description I will go into details: The control which is added to the main form is a derived Panel, which has a data variable which contains the color of this Panel. The data is stored in a Color array and passed to the constructor of the panel
for( int i=0; i < color.Length; i++ )
{
ColorPanel pan = new ColorPanel( ref colors[i] )
this.Controls.Add( pan );
}
However the theory is not matching the practise. If I change one item of the colors array and redraw the main form, the color of the colorpanel is not changed. Of course, I overwrote the ColorPanel OnPaint method to set the particular background color. The trace output showed that the old color value is still existing...
So, how to pass a reference packed in an array in c#?
Thanks,
gbr