how to update combobox item simply in propertygrid?

Grids for WPF Forum

Posted 10 years ago by john erik
Version: 11.1.0545
Avatar

hi,

 

i have question in my project.

first view my source.

 

// class

public class TestObject

{

private string testString;

[Browsable(true)]

[SortOrder(1)]

[TypeConverter(typeof(MyConverter))]

public string TEST

{

get

{

string S = "";

if (testString != null)

{

S = testString;

}

return S;

}

set { testString = value; }

}

}

internal class Gloabal

{

internal static string[] data;

}

public class MyConverter : StringConverter

{

public override bool GetStandardValuesSupported(ITypeDescriptorContext context)

{

return true;

}

public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)

{

return true;

}

public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)

{

return new StandardValuesCollection(Gloabal.data);

}

}

// main

public partial class MainControl : Window

{

public MainControl()

{

InitializeComponent();

this.PropertyGrid1.SelectedObject = new TestObject();

UpdateListofRules(10);

}

private void UpdateListofRules(int total)

{

Gloabal.data = new string[total];

for (int i = 0; i <= total - 1; i++)

{

Gloabal.data[i] = "A" + i;

}

}

private void button1_Click(object sender, RoutedEventArgs e)

{

UpdateListofRules(20);

}

}

 

when first load string array has 10 field and display as combobox has "A1", "A2" ... "A10".

when btn1 pressed, i hope display 20 field in combobox. but still combobox display 10 field.

if using propertygrid1.refresh, then display 20 field. but i want to update specific area. 

how to update combobox, not using refresh?

Comments (3)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi John,

If you are building your ComboBox in the way that you are, the only way to update it is to do a refresh since that's when the property's value editor is reconstructed.  Note that there are several overloads of Refresh.  For instance if you know the current value of the property TEST, you could do something like:

propertygrid1.Refresh(myobj.TEST, PropertyRefreshBehavior.ValueOnly);

That would only refresh properties that have the specified value and not the entire PropertyGrid.

The other option would be to build a custom property value editor and have the ComboBox in the value editor's template bind to some static data source that you update.  But it sounds like the first option would be better.


Actipro Software Support

Posted 10 years ago by john erik
Avatar

hi,

 

i try your suggestion, but i have nothing overload of refresh.

please let me know other option.

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

I see you are running an older version 2011.1.  Some of those Refresh method overloads were added in the newer versions.  The two options I gave are really the only things you can do for this.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.