469,283 Members | 2,263 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,283 developers. It's quick & easy.

how to create a property with drop options???

Hi,

I'm trying to create a property in a class that should be apepar as
dropdown combo at design time with X options. Something like the
WindowStateProperty where you can select 3 options. How can this be done
I've tried several ways but can't get it to work. Whta am I doing wrong?.
This is what I have in the class

private ComboBox fieldType= new ComboBox();
private DataTable dtFieldType;
loadCombo();
[
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
Editor(typeof(System.ComponentModel.Design.Collect ionEditor),
typeof(System.Drawing.Design.UITypeEditor)),
Description("Type you want to display")
]
public ComboBox FieldType
{
get
{
return dtFieldType;
}
set
{
dtFieldType= value;
}
}

private LoadCombo()
{
this.dtFieldType= new DataTable();
this.dtFieldType.Columns.Add("Type");
//============================================
DataRow drFieldType = dtFieldType.NewRow();
drFieldType ["Type"] = "String";
dtFieldType.Rows.Add(drFieldType);
//============================================
drFieldType = dtFieldType.NewRow();
drFieldType ["Type"] = "Date";
this.dtFieldType.Rows.Add(drFieldType);
//============================================
drFieldType = dtFieldType.NewRow();
drFieldType ["Type"] = "Numeric";
this.dtFieldType.Rows.Add(drFieldType);
//===
tipoCampo.DataSource = this.dtFieldType;
tipoCampo.DisplayMember = "Type";
tipoCampo.ValueMember = "Type";
}
The combo does show up in Design time but no options are present.

Help is really appreciated
Lucas

Nov 15 '05 #1
1 1019
I got it to work. I forgot about enumerators and they did the trick.
Oooppsss

Regards
Lucas

"Lucas Sain" <ls***@lidersoft.com> wrote in message
news:uU**************@TK2MSFTNGP12.phx.gbl...
Hi,

I'm trying to create a property in a class that should be apepar as
dropdown combo at design time with X options. Something like the
WindowStateProperty where you can select 3 options. How can this be done
I've tried several ways but can't get it to work. Whta am I doing wrong?.
This is what I have in the class

private ComboBox fieldType= new ComboBox();
private DataTable dtFieldType;
loadCombo();
[
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content), Editor(typeof(System.ComponentModel.Design.Collect ionEditor),
typeof(System.Drawing.Design.UITypeEditor)),
Description("Type you want to display")
]
public ComboBox FieldType
{
get
{
return dtFieldType;
}
set
{
dtFieldType= value;
}
}

private LoadCombo()
{
this.dtFieldType= new DataTable();
this.dtFieldType.Columns.Add("Type");
//============================================
DataRow drFieldType = dtFieldType.NewRow();
drFieldType ["Type"] = "String";
dtFieldType.Rows.Add(drFieldType);
//============================================
drFieldType = dtFieldType.NewRow();
drFieldType ["Type"] = "Date";
this.dtFieldType.Rows.Add(drFieldType);
//============================================
drFieldType = dtFieldType.NewRow();
drFieldType ["Type"] = "Numeric";
this.dtFieldType.Rows.Add(drFieldType);
//===
tipoCampo.DataSource = this.dtFieldType;
tipoCampo.DisplayMember = "Type";
tipoCampo.ValueMember = "Type";
}
The combo does show up in Design time but no options are present.

Help is really appreciated
Lucas

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Greg Scharlemann | last post: by
2 posts views Thread by Arpan | last post: by
2 posts views Thread by ECVerify.com | last post: by
1 post views Thread by abTech | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.