473,383 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

design time editvalue / uitypeeditor dirty


I have a custom collection in my c# winform ui control called Items.
Items is a built in collection type that does not allow itself to be
replace (you can't 'set' the itemscollection in the control).
However, the contents of the Items collection is persisted through
designtime.

Currently this all works except for the following. When you bring up
the custom collection editor and add new items then close the
collection editor.

I add the items to the base control in the editvalue after success by
getting a reference to the control, clearing the items collection,
then re-adding all the items.

This all works except for one catch, it never thinks the collection
has changed. Since there is no 'Set' accessor on the collection in
the base control, for some reason the design time refuses to believe
it is changable even though it's been edited.

Now if I resize the control or change some other property, it puts the
little star on the forms name and when you save it properly serializes
the items collection.

So I need to know if there is a way in editvalue to force the designer
to know that the items collection is dirty (hence putting up the
little star in the name) so they can save and have it serialize out.

Dec 18 '05 #1
13 7853
I think you should use RefreshPropertiesAttribute.

[RefreshProperties(RefreshProperties.All)]

FooCollection FooProperties
"alex sparsky" <al**@sparkysystems.com> wrote in message
news:bp********************************@4ax.com...

I have a custom collection in my c# winform ui control called Items.
Items is a built in collection type that does not allow itself to be
replace (you can't 'set' the itemscollection in the control).
However, the contents of the Items collection is persisted through
designtime.

Currently this all works except for the following. When you bring up
the custom collection editor and add new items then close the
collection editor.

I add the items to the base control in the editvalue after success by
getting a reference to the control, clearing the items collection,
then re-adding all the items.

This all works except for one catch, it never thinks the collection
has changed. Since there is no 'Set' accessor on the collection in
the base control, for some reason the design time refuses to believe
it is changable even though it's been edited.

Now if I resize the control or change some other property, it puts the
little star on the forms name and when you save it properly serializes
the items collection.

So I need to know if there is a way in editvalue to force the designer
to know that the items collection is dirty (hence putting up the
little star in the name) so they can save and have it serialize out.

Dec 19 '05 #2
Tried that already and it made no difference. I'm still looking for a solution to this.
On Mon, 19 Dec 2005 20:00:18 +0200, "Bele din Carpati" <cr*******@mail.dntis.ro> wrote:
I think you should use RefreshPropertiesAttribute.

[RefreshProperties(RefreshProperties.All)]

FooCollection FooProperties
"alex sparsky" <al**@sparkysystems.com> wrote in message
news:bp********************************@4ax.com.. .

I have a custom collection in my c# winform ui control called Items.
Items is a built in collection type that does not allow itself to be
replace (you can't 'set' the itemscollection in the control).
However, the contents of the Items collection is persisted through
designtime.

Currently this all works except for the following. When you bring up
the custom collection editor and add new items then close the
collection editor.

I add the items to the base control in the editvalue after success by
getting a reference to the control, clearing the items collection,
then re-adding all the items.

This all works except for one catch, it never thinks the collection
has changed. Since there is no 'Set' accessor on the collection in
the base control, for some reason the design time refuses to believe
it is changable even though it's been edited.

Now if I resize the control or change some other property, it puts the
little star on the forms name and when you save it properly serializes
the items collection.

So I need to know if there is a way in editvalue to force the designer
to know that the items collection is dirty (hence putting up the
little star in the name) so they can save and have it serialize out.


Dec 19 '05 #3
than try DesignerSerializationVisibilityAttribute

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:cq********************************@4ax.com...
Tried that already and it made no difference. I'm still looking for a
solution to this.
On Mon, 19 Dec 2005 20:00:18 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
I think you should use RefreshPropertiesAttribute.

[RefreshProperties(RefreshProperties.All)]

FooCollection FooProperties
"alex sparsky" <al**@sparkysystems.com> wrote in message
news:bp********************************@4ax.com. ..

I have a custom collection in my c# winform ui control called Items.
Items is a built in collection type that does not allow itself to be
replace (you can't 'set' the itemscollection in the control).
However, the contents of the Items collection is persisted through
designtime.

Currently this all works except for the following. When you bring up
the custom collection editor and add new items then close the
collection editor.

I add the items to the base control in the editvalue after success by
getting a reference to the control, clearing the items collection,
then re-adding all the items.

This all works except for one catch, it never thinks the collection
has changed. Since there is no 'Set' accessor on the collection in
the base control, for some reason the design time refuses to believe
it is changable even though it's been edited.

Now if I resize the control or change some other property, it puts the
little star on the forms name and when you save it properly serializes
the items collection.

So I need to know if there is a way in editvalue to force the designer
to know that the items collection is dirty (hence putting up the
little star in the name) so they can save and have it serialize out.

Dec 19 '05 #4
see how the Controls property of Control object is marked with
DesignerSerializationVisibility:

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
System.Windows.Forms.SRDescription("ControlControl sDescr"),
Browsable(false)]
public System.Windows.Forms.Control.ControlCollection Controls

{

get{....}

set{...}

}

Can you please let me know if this is helped you?

Cristi

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:cq********************************@4ax.com...
Tried that already and it made no difference. I'm still looking for a
solution to this.
On Mon, 19 Dec 2005 20:00:18 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
I think you should use RefreshPropertiesAttribute.

[RefreshProperties(RefreshProperties.All)]

FooCollection FooProperties
"alex sparsky" <al**@sparkysystems.com> wrote in message
news:bp********************************@4ax.com. ..

I have a custom collection in my c# winform ui control called Items.
Items is a built in collection type that does not allow itself to be
replace (you can't 'set' the itemscollection in the control).
However, the contents of the Items collection is persisted through
designtime.

Currently this all works except for the following. When you bring up
the custom collection editor and add new items then close the
collection editor.

I add the items to the base control in the editvalue after success by
getting a reference to the control, clearing the items collection,
then re-adding all the items.

This all works except for one catch, it never thinks the collection
has changed. Since there is no 'Set' accessor on the collection in
the base control, for some reason the design time refuses to believe
it is changable even though it's been edited.

Now if I resize the control or change some other property, it puts the
little star on the forms name and when you save it properly serializes
the items collection.

So I need to know if there is a way in editvalue to force the designer
to know that the items collection is dirty (hence putting up the
little star in the name) so they can save and have it serialize out.

Dec 19 '05 #5
[
Description("Items Collection"),
Category("Items"),
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
Editor(typeof(GItemEditor), typeof(UITypeEditor)),
RefreshProperties(RefreshProperties.All),
Browsable( true )
]

and none of those things are helping. :/

this is the header I've already been using.
On Mon, 19 Dec 2005 21:42:00 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
see how the Controls property of Control object is marked with
DesignerSerializationVisibility:

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
System.Windows.Forms.SRDescription("ControlContro lsDescr"),
Browsable(false)]
public System.Windows.Forms.Control.ControlCollection Controls

{

get{....}

set{...}

}

Can you please let me know if this is helped you?

Cristi

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:cq********************************@4ax.com.. .
Tried that already and it made no difference. I'm still looking for a
solution to this.
On Mon, 19 Dec 2005 20:00:18 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
I think you should use RefreshPropertiesAttribute.

[RefreshProperties(RefreshProperties.All)]

FooCollection FooProperties

Dec 19 '05 #6
I created a sample UserControl that exposes a Collection
Serialization works in this sample, the single problem I found is that I
want to have an edit updated with number of items in the collection. For
that I had to call Control.Refresh() when CollectionEditor.SetItems() is
called. Can you please use this sample and tell if it is close to what you
need?
Tip1: I have to restart VStudio 2005 quite often (almost each time I modify
control)
Tip 2: I use dbmon or DbgView (from www.sysinternals.com) to see the output
of System.Diagonostics.Trace.WriteLine even if is in VStudio Designer

Here follows the source code
TestUserControl.cs
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Drawing;

using System.Data;

using System.Text;

using System.Windows.Forms;

using System.Collections.ObjectModel;

using System.Drawing.Design;

using System.ComponentModel.Design;

namespace TestCollectionProperty

{

public class TestData

{

int intValue;

String strValue = string.Empty;

public int IntValue

{

get { return intValue; }

set { intValue = value; }

}
public String StrValue

{

get { return strValue; }

set { strValue = value; }

}

}

public class ValuesEditor : CollectionEditor

{

public ValuesEditor()

: base(typeof(List<TestData>))

{ }

protected override object SetItems(object editValue, object[] value)

{

System.Diagnostics.Trace.WriteLine("SetItems1");

System.Diagnostics.Trace.WriteLine("SetItems2: " + editValue);
object retValue = base.SetItems(editValue, value);

Control control = this.Context.Instance as Control;

System.Diagnostics.Trace.WriteLine("SetItems3: " + control);

if (control != null)

{

control.Refresh();

}

return retValue;

}

}

public partial class TestUserControl : UserControl

{

private List<TestData> values = new List<TestData>();

public TestUserControl()

{

InitializeComponent();

}

[Browsable(true)]

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]

[RefreshProperties(RefreshProperties.All)]

[Editor(typeof(ValuesEditor), typeof(UITypeEditor))]

public List<TestData> Values

{

get { return values; }

}

protected override void OnPaint(PaintEventArgs e)

{

this.textBox.Text = values.Count.ToString();

base.OnPaint(e);

}

}

}

TestUserCode.Design.cs

namespace TestCollectionProperty

{

partial class TestUserControl

{

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.IContainer components = null;

/// <summary>

/// Clean up any resources being used.

/// </summary>

/// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>

protected override void Dispose(bool disposing)

{

if (disposing && (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()

{

this.textBox = new System.Windows.Forms.TextBox();

this.SuspendLayout();

//

// textBox

//

this.textBox.Location = new System.Drawing.Point(24, 50);

this.textBox.Name = "textBox";

this.textBox.Size = new System.Drawing.Size(100, 20);

this.textBox.TabIndex = 0;

//

// TestUserControl

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.Controls.Add(this.textBox);

this.Name = "TestUserControl";

this.ResumeLayout(false);

this.PerformLayout();

}

#endregion

private System.Windows.Forms.TextBox textBox;

}

}



"alex sparsky" <al**@sparkysystems.com> wrote in message
news:si********************************@4ax.com...
[
Description("Items Collection"),
Category("Items"),
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
Editor(typeof(GItemEditor), typeof(UITypeEditor)),
RefreshProperties(RefreshProperties.All),
Browsable( true )
]

and none of those things are helping. :/

this is the header I've already been using.
On Mon, 19 Dec 2005 21:42:00 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
see how the Controls property of Control object is marked with
DesignerSerializationVisibility:

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
System.Windows.Forms.SRDescription("ControlContr olsDescr"),
Browsable(false)]
public System.Windows.Forms.Control.ControlCollection Controls

{

get{....}

set{...}

}

Can you please let me know if this is helped you?

Cristi

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:cq********************************@4ax.com. ..
Tried that already and it made no difference. I'm still looking for a
solution to this.
On Mon, 19 Dec 2005 20:00:18 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:

I think you should use RefreshPropertiesAttribute.

[RefreshProperties(RefreshProperties.All)]

FooCollection FooProperties

Dec 19 '05 #7
For a short period of time the project can be downloaded from:
http://www.geocities.com/balcanuc/Te...onProperty.zip
"Bele din Carpati" <cr*******@mail.dntis.ro> wrote in message
news:uS****************@TK2MSFTNGP11.phx.gbl...
I created a sample UserControl that exposes a Collection
Serialization works in this sample, the single problem I found is that I
want to have an edit updated with number of items in the collection. For
that I had to call Control.Refresh() when CollectionEditor.SetItems() is
called. Can you please use this sample and tell if it is close to what you
need?
Tip1: I have to restart VStudio 2005 quite often (almost each time I
modify control)
Tip 2: I use dbmon or DbgView (from www.sysinternals.com) to see the
output of System.Diagonostics.Trace.WriteLine even if is in VStudio
Designer

Here follows the source code
TestUserControl.cs
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Drawing;

using System.Data;

using System.Text;

using System.Windows.Forms;

using System.Collections.ObjectModel;

using System.Drawing.Design;

using System.ComponentModel.Design;

namespace TestCollectionProperty

{

public class TestData

{

int intValue;

String strValue = string.Empty;

public int IntValue

{

get { return intValue; }

set { intValue = value; }

}
public String StrValue

{

get { return strValue; }

set { strValue = value; }

}

}

public class ValuesEditor : CollectionEditor

{

public ValuesEditor()

: base(typeof(List<TestData>))

{ }

protected override object SetItems(object editValue, object[] value)

{

System.Diagnostics.Trace.WriteLine("SetItems1");

System.Diagnostics.Trace.WriteLine("SetItems2: " + editValue);
object retValue = base.SetItems(editValue, value);

Control control = this.Context.Instance as Control;

System.Diagnostics.Trace.WriteLine("SetItems3: " + control);

if (control != null)

{

control.Refresh();

}

return retValue;

}

}

public partial class TestUserControl : UserControl

{

private List<TestData> values = new List<TestData>();

public TestUserControl()

{

InitializeComponent();

}

[Browsable(true)]

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]

[RefreshProperties(RefreshProperties.All)]

[Editor(typeof(ValuesEditor), typeof(UITypeEditor))]

public List<TestData> Values

{

get { return values; }

}

protected override void OnPaint(PaintEventArgs e)

{

this.textBox.Text = values.Count.ToString();

base.OnPaint(e);

}

}

}

TestUserCode.Design.cs

namespace TestCollectionProperty

{

partial class TestUserControl

{

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.IContainer components = null;

/// <summary>

/// Clean up any resources being used.

/// </summary>

/// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>

protected override void Dispose(bool disposing)

{

if (disposing && (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()

{

this.textBox = new System.Windows.Forms.TextBox();

this.SuspendLayout();

//

// textBox

//

this.textBox.Location = new System.Drawing.Point(24, 50);

this.textBox.Name = "textBox";

this.textBox.Size = new System.Drawing.Size(100, 20);

this.textBox.TabIndex = 0;

//

// TestUserControl

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.Controls.Add(this.textBox);

this.Name = "TestUserControl";

this.ResumeLayout(false);

this.PerformLayout();

}

#endregion

private System.Windows.Forms.TextBox textBox;

}

}



"alex sparsky" <al**@sparkysystems.com> wrote in message
news:si********************************@4ax.com...
[
Description("Items Collection"),
Category("Items"),
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
Editor(typeof(GItemEditor), typeof(UITypeEditor)),
RefreshProperties(RefreshProperties.All),
Browsable( true )
]

and none of those things are helping. :/

this is the header I've already been using.
On Mon, 19 Dec 2005 21:42:00 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
see how the Controls property of Control object is marked with
DesignerSerializationVisibility:

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
System.Windows.Forms.SRDescription("ControlCont rolsDescr"),
Browsable(false)]
public System.Windows.Forms.Control.ControlCollection Controls

{

get{....}

set{...}

}

Can you please let me know if this is helped you?

Cristi

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:cq********************************@4ax.com ...
Tried that already and it made no difference. I'm still looking for a
solution to this.
On Mon, 19 Dec 2005 20:00:18 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:

>I think you should use RefreshPropertiesAttribute.
>
>[RefreshProperties(RefreshProperties.All)]
>
>FooCollection FooProperties
>
>


Dec 19 '05 #8
Hey, I really apprecaite you sending me the example project. I took a
look at it and there is one major thing your doing differently from
me. I'm implementing my own collection editor so I'm deriving from
UITypeEditor instead of CollectionEditor. So basically the routines
that I have to pick from are EditValue().

The crux of my problem seems to be somewhere in the fact that since
there is no Set accessor in the Items collection property then it
doesn't seem to matter what I return from the EditValue override in
the UITypeEditor.

So like I said, it sets the collection correctly, it puts the items
into it (well, it does because I put them in manually from the
editvalue in the uitypeeditor). The problem is that it's not setting
the dirty bit or whatever it is to make the form believe that the
collection changed. So you have to resize the control or something to
make it want to reserialize the collection. Once you do that though
the collection is set and serializes fine.

On Tue, 20 Dec 2005 00:59:06 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
I created a sample UserControl that exposes a Collection
Serialization works in this sample, the single problem I found is that I
want to have an edit updated with number of items in the collection. For
that I had to call Control.Refresh() when CollectionEditor.SetItems() is
called. Can you please use this sample and tell if it is close to what you
need?
Tip1: I have to restart VStudio 2005 quite often (almost each time I modify
control)
Tip 2: I use dbmon or DbgView (from www.sysinternals.com) to see the output
of System.Diagonostics.Trace.WriteLine even if is in VStudio Designer


Dec 20 '05 #9
I get it. I guess that you have to notify the designer about change using
the IComponentChange service
I used reflector to check how the CollectionEditor does this and seems that
you have to add one more line to your EditValue override:
this.Context.OnComponentChanged();

Cristi

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:35********************************@4ax.com...
Hey, I really apprecaite you sending me the example project. I took a
look at it and there is one major thing your doing differently from
me. I'm implementing my own collection editor so I'm deriving from
UITypeEditor instead of CollectionEditor. So basically the routines
that I have to pick from are EditValue().

The crux of my problem seems to be somewhere in the fact that since
there is no Set accessor in the Items collection property then it
doesn't seem to matter what I return from the EditValue override in
the UITypeEditor.

So like I said, it sets the collection correctly, it puts the items
into it (well, it does because I put them in manually from the
editvalue in the uitypeeditor). The problem is that it's not setting
the dirty bit or whatever it is to make the form believe that the
collection changed. So you have to resize the control or something to
make it want to reserialize the collection. Once you do that though
the collection is set and serializes fine.

On Tue, 20 Dec 2005 00:59:06 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
I created a sample UserControl that exposes a Collection
Serialization works in this sample, the single problem I found is that I
want to have an edit updated with number of items in the collection. For
that I had to call Control.Refresh() when CollectionEditor.SetItems() is
called. Can you please use this sample and tell if it is close to what you
need?
Tip1: I have to restart VStudio 2005 quite often (almost each time I
modify
control)
Tip 2: I use dbmon or DbgView (from www.sysinternals.com) to see the
output
of System.Diagonostics.Trace.WriteLine even if is in VStudio Designer

Dec 20 '05 #10
woohooo! That was the magic call I was looking for. I didn't see
that method in intellisense or the docs when I went looking for it. I
wonder why that wasn't there! Nice job, I really appreciate it. This
works perfectly now.

On Tue, 20 Dec 2005 08:53:06 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
I get it. I guess that you have to notify the designer about change using
the IComponentChange service
I used reflector to check how the CollectionEditor does this and seems that
you have to add one more line to your EditValue override:
this.Context.OnComponentChanged();

Cristi

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:35********************************@4ax.com.. .
Hey, I really apprecaite you sending me the example project. I took a
look at it and there is one major thing your doing differently from
me. I'm implementing my own collection editor so I'm deriving from
UITypeEditor instead of CollectionEditor. So basically the routines
that I have to pick from are EditValue().

The crux of my problem seems to be somewhere in the fact that since
there is no Set accessor in the Items collection property then it
doesn't seem to matter what I return from the EditValue override in
the UITypeEditor.

So like I said, it sets the collection correctly, it puts the items
into it (well, it does because I put them in manually from the
editvalue in the uitypeeditor). The problem is that it's not setting
the dirty bit or whatever it is to make the form believe that the
collection changed. So you have to resize the control or something to
make it want to reserialize the collection. Once you do that though
the collection is set and serializes fine.

On Tue, 20 Dec 2005 00:59:06 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
I created a sample UserControl that exposes a Collection
Serialization works in this sample, the single problem I found is that I
want to have an edit updated with number of items in the collection. For
that I had to call Control.Refresh() when CollectionEditor.SetItems() is
called. Can you please use this sample and tell if it is close to what you
need?
Tip1: I have to restart VStudio 2005 quite often (almost each time I
modify
control)
Tip 2: I use dbmon or DbgView (from www.sysinternals.com) to see the
output
of System.Diagonostics.Trace.WriteLine even if is in VStudio Designer


Dec 20 '05 #11
I'm happy to hear that my advices helped you.
Here another tip: use reflector to see how the CollectionEditor creates a
transaction for property change. This helps designer to mark undo/redo
changes as only one step. ;) (I guess).
key lines related to transaction:
IDesignerHost host1 = (IDesignerHost)
this.GetService(typeof(IDesignerHost));
DesignerTransaction transaction1 = null;

......

transaction1 =
host1.CreateTransaction(System.Design.SR.GetString ("CollectionEditorUndoBatchDesc",
objArray1));

......

transaction1.Commit();
- Cristi

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:gh********************************@4ax.com...
woohooo! That was the magic call I was looking for. I didn't see
that method in intellisense or the docs when I went looking for it. I
wonder why that wasn't there! Nice job, I really appreciate it. This
works perfectly now.

On Tue, 20 Dec 2005 08:53:06 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
I get it. I guess that you have to notify the designer about change using
the IComponentChange service
I used reflector to check how the CollectionEditor does this and seems
that
you have to add one more line to your EditValue override:
this.Context.OnComponentChanged();

Cristi

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:35********************************@4ax.com. ..
Hey, I really apprecaite you sending me the example project. I took a
look at it and there is one major thing your doing differently from
me. I'm implementing my own collection editor so I'm deriving from
UITypeEditor instead of CollectionEditor. So basically the routines
that I have to pick from are EditValue().

The crux of my problem seems to be somewhere in the fact that since
there is no Set accessor in the Items collection property then it
doesn't seem to matter what I return from the EditValue override in
the UITypeEditor.

So like I said, it sets the collection correctly, it puts the items
into it (well, it does because I put them in manually from the
editvalue in the uitypeeditor). The problem is that it's not setting
the dirty bit or whatever it is to make the form believe that the
collection changed. So you have to resize the control or something to
make it want to reserialize the collection. Once you do that though
the collection is set and serializes fine.

On Tue, 20 Dec 2005 00:59:06 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:

I created a sample UserControl that exposes a Collection
Serialization works in this sample, the single problem I found is that I
want to have an edit updated with number of items in the collection. For
that I had to call Control.Refresh() when CollectionEditor.SetItems() is
called. Can you please use this sample and tell if it is close to what
you
need?
Tip1: I have to restart VStudio 2005 quite often (almost each time I
modify
control)
Tip 2: I use dbmon or DbgView (from www.sysinternals.com) to see the
output
of System.Diagonostics.Trace.WriteLine even if is in VStudio Designer

Dec 20 '05 #12
Great advice, I will do that.

thanks again

On Tue, 20 Dec 2005 21:51:38 +0200, "Bele din Carpati" <cr*******@mail.dntis.ro> wrote:
I'm happy to hear that my advices helped you.
Here another tip: use reflector to see how the CollectionEditor creates a
transaction for property change. This helps designer to mark undo/redo
changes as only one step. ;) (I guess).
key lines related to transaction:
IDesignerHost host1 = (IDesignerHost)
this.GetService(typeof(IDesignerHost));
DesignerTransaction transaction1 = null;

.....

transaction1 =
host1.CreateTransaction(System.Design.SR.GetStrin g("CollectionEditorUndoBatchDesc",
objArray1));

.....

transaction1.Commit();
- Cristi

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:gh********************************@4ax.com.. .
woohooo! That was the magic call I was looking for. I didn't see
that method in intellisense or the docs when I went looking for it. I
wonder why that wasn't there! Nice job, I really appreciate it. This
works perfectly now.

On Tue, 20 Dec 2005 08:53:06 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
I get it. I guess that you have to notify the designer about change using
the IComponentChange service
I used reflector to check how the CollectionEditor does this and seems
that
you have to add one more line to your EditValue override:
this.Context.OnComponentChanged();

Cristi

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:35********************************@4ax.com ...
Hey, I really apprecaite you sending me the example project. I took a
look at it and there is one major thing your doing differently from
me. I'm implementing my own collection editor so I'm deriving from
UITypeEditor instead of CollectionEditor. So basically the routines
that I have to pick from are EditValue().

The crux of my problem seems to be somewhere in the fact that since
there is no Set accessor in the Items collection property then it
doesn't seem to matter what I return from the EditValue override in
the UITypeEditor.

So like I said, it sets the collection correctly, it puts the items
into it (well, it does because I put them in manually from the
editvalue in the uitypeeditor). The problem is that it's not setting
the dirty bit or whatever it is to make the form believe that the
collection changed. So you have to resize the control or something to
make it want to reserialize the collection. Once you do that though
the collection is set and serializes fine.

On Tue, 20 Dec 2005 00:59:06 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:

>I created a sample UserControl that exposes a Collection
>Serialization works in this sample, the single problem I found is that I
>want to have an edit updated with number of items in the collection. For
>that I had to call Control.Refresh() when CollectionEditor.SetItems() is
>called. Can you please use this sample and tell if it is close to what
>you
>need?
>Tip1: I have to restart VStudio 2005 quite often (almost each time I
>modify
>control)
>Tip 2: I use dbmon or DbgView (from www.sysinternals.com) to see the
>output
>of System.Diagonostics.Trace.WriteLine even if is in VStudio Designer
>


Dec 20 '05 #13
It's probably a mute point now since you guys nicely worked out this issue.
The following topics touch on the topic at hand:

http://msdn.microsoft.com/library/de...classtopic.asp

http://msdn2.microsoft.com/en-us/lib...t_members.aspx

http://msdn2.microsoft.com/en-us/lib....setvalue.aspx
"alex sparsky" <al**@sparkysystems.com> wrote in message
news:gh********************************@4ax.com...
woohooo! That was the magic call I was looking for. I didn't see
that method in intellisense or the docs when I went looking for it. I
wonder why that wasn't there! Nice job, I really appreciate it. This
works perfectly now.

On Tue, 20 Dec 2005 08:53:06 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:
I get it. I guess that you have to notify the designer about change using
the IComponentChange service
I used reflector to check how the CollectionEditor does this and seems
that
you have to add one more line to your EditValue override:
this.Context.OnComponentChanged();

Cristi

"alex sparsky" <al**@sparkysystems.com> wrote in message
news:35********************************@4ax.com. ..
Hey, I really apprecaite you sending me the example project. I took a
look at it and there is one major thing your doing differently from
me. I'm implementing my own collection editor so I'm deriving from
UITypeEditor instead of CollectionEditor. So basically the routines
that I have to pick from are EditValue().

The crux of my problem seems to be somewhere in the fact that since
there is no Set accessor in the Items collection property then it
doesn't seem to matter what I return from the EditValue override in
the UITypeEditor.

So like I said, it sets the collection correctly, it puts the items
into it (well, it does because I put them in manually from the
editvalue in the uitypeeditor). The problem is that it's not setting
the dirty bit or whatever it is to make the form believe that the
collection changed. So you have to resize the control or something to
make it want to reserialize the collection. Once you do that though
the collection is set and serializes fine.

On Tue, 20 Dec 2005 00:59:06 +0200, "Bele din Carpati"
<cr*******@mail.dntis.ro> wrote:

I created a sample UserControl that exposes a Collection
Serialization works in this sample, the single problem I found is that I
want to have an edit updated with number of items in the collection. For
that I had to call Control.Refresh() when CollectionEditor.SetItems() is
called. Can you please use this sample and tell if it is close to what
you
need?
Tip1: I have to restart VStudio 2005 quite often (almost each time I
modify
control)
Tip 2: I use dbmon or DbgView (from www.sysinternals.com) to see the
output
of System.Diagonostics.Trace.WriteLine even if is in VStudio Designer

Dec 21 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James Doran | last post by:
Hello, I'd like to iterate through each Page of my ASP.NET project from within a Custom web control and access the Page.Controls collection. I've tried using Reflection on the web project...
0
by: Andre Fledge | last post by:
Hello , I have very mystic problem : I have control, derrived from DataSourceControl, I have property SelectExpression public SelectExpression SelectExpression { get {
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
2
by: Ahmed Hashish | last post by:
In building controls we need to create Custom UITypeEditor classes, most of this classes (in my case) doing the same job, its used to support the controls properties with a drop down list contains...
0
by: pyda001 | last post by:
Hi yall! I have created an image selection dropdown editor for use in a PropertyGrid. My selector form is called dropdown by a IWindowsFormsEditorService and so far it's all sweet. On my...
1
by: David Veeneman | last post by:
I'm backporting a component to .NET 1.x, and it required me to use a custom collection, StringList, instead of List<string>. StringList is derived from CollectionBase and is marked serializable. ...
0
by: AP Farszha | last post by:
Hello groovers, I have a component which i'm trying to add some design time support to. I wish to add design time support so that a readonly collection of ToolStripItems can be maintained via a...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
6
by: ajk | last post by:
Hi I was wondering how to show different properties in design and run-mode for a user control? Is it possible to do this when implementing the System.ComponentModel.ICustomTypeDescriptor...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.