|
-
March 24th, 2005, 02:47 AM
#1
PropertyGrid doesn't load correct float[] property values
I have a strange problem.
I have defined a windows component class in which there is a float [] private member like this:
private float [] m_Directions = new float[] {0,1,2};
Then I have created a property for setting and retrieving values of such a member, with designer support, like this:
[
Browsable(true),
Category("Blend settings")
]
public float[] Directions
{
get
{
return m_directions;
}
set
{
m_directions = value;
}
}
When I am in design mode, setting of float[] goes well, (and I find updated values in InitializeComponent() method. Correct!
When I shutdown .NET Devenv and then reopen my project, designer doesn't load
the last values for m_Directions array, but the old ones {0,1,2}. Why?
Is there a way to tell designer to load values from InitializeComponent() method?
Any idea?
thank you very much in advance!
JIT
-
March 24th, 2005, 02:53 AM
#2
Re: PropertyGrid doesn't load correct float[] property values
Does this happen at runtime as well?
Useful? Then click on (Rate This Post) at the top of this post.
-
March 24th, 2005, 02:54 AM
#3
Re: PropertyGrid doesn't load correct float[] property values
 Originally Posted by Norfy
Does this happen at runtime as well?
No, at runtime everything is correct.
I would like to tell designer to reload new values when devent loads, from InitializeComponents(), ... but how?
-
March 24th, 2005, 03:00 AM
#4
Re: PropertyGrid doesn't load correct float[] property values
Does this make any difference?
Code:
[
Browsable(true),
Category("Blend settings")
]
public float[] Directions
{
get
{
return m_directions;
}
set
{
m_directions = value;
Invalidate();
}
}
If not can you post (or email) a complete component?
Useful? Then click on (Rate This Post) at the top of this post.
-
March 24th, 2005, 03:11 AM
#5
Re: PropertyGrid doesn't load correct float[] property values
 Originally Posted by Norfy
Does this make any difference?
Code:
[
Browsable(true),
Category("Blend settings")
]
public float[] Directions
{
get
{
return m_directions;
}
set
{
m_directions = value;
Invalidate();
}
}
If not can you post (or email) a complete component?
Same problem. This is my component (a simple Panel):
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
namespace WinApp
{
/// <summary>
/// Summary description for MyPanel.
/// </summary>
public class MyPanel : System.Windows.Forms.Panel
{
private float [] m_directions = new float[]{0,0,1};
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public MyPanel(System.ComponentModel.IContainer container)
{
///
/// Required for Windows.Forms Class Composition Designer support
///
container.Add(this);
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
public MyPanel()
{
///
/// Required for Windows.Forms Class Composition Designer support
///
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
[
Browsable(true),
Category("Blend settings")
]
public float[] Directions
{
get
{
return m_directions;
}
set
{
m_directions = value;
Invalidate();
}
}
}
}
-
March 24th, 2005, 03:37 AM
#6
Re: PropertyGrid doesn't load correct float[] property values
I found a MS Article about a similar problem with double array...
http://support.microsoft.com/default...b;EN-US;832924
In fact 2 minutes ago I noticed the following error at design time:
" At least one element in the source array could not be cast down to the destination array type."
-
March 24th, 2005, 03:45 AM
#7
Re: PropertyGrid doesn't load correct float[] property values
I noticed the design time error message as well.
I know the bug report mentions some workarounds, but Instead of using float/double you could also use int and express your values as percentages.
Useful? Then click on (Rate This Post) at the top of this post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|