CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Jun 2005
    Posts
    66

    Question about references

    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

    Code:
    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
    Last edited by gbr; July 23rd, 2005 at 10:02 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured