473,699 Members | 2,717 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom property grid doesn't show collections

I have a custom property grid. I am using custom property grid as I do
not want the error messages that the propertygrid shows when abphabets
are entered in interger fields.

The custom property grid doesn't show colloections i.e. if I have a
List<Objectthen the Collection is shown but when I click on the
"..." button next to it nothing comes up.

If I say CustomPropertyG rid p = new CustomPropertyG rid();
p.SelectedObjec t = new ComboBox();

Notice that if the "..." button after the collection is clicked
nothing comes up.
Can someone please help.
Here is the custom property grid

using System;
using System.Componen tModel;
using System.Collecti ons.Generic;
using System.Diagnost ics;
using System.Text;
using System.Windows. Forms;
using System.Windows. Forms.Design;
using System.Reflecti on;
using System.Collecti ons;

namespace TestPropertyGri d
{
public partial class CustomPropertyG rid : PropertyGrid
{
#region -- Members
private CustomPropertyG ridService m_customPropert yGridService
= null; // Custom Property Grid Service
#endregion Members

#region -- Constructor
/// <summary>Create s the custom property grid component.</
summary>
public CustomPropertyG rid()
{
// Initialize
InitializeCompo nent();
// Create the custom validation service
m_customPropert yGridService = new
CustomPropertyG ridService(this );
// Set the custom property grid to use the custom property
grid validation service
FieldInfo fieldGridView =
typeof(Property Grid).GetField( "gridView", BindingFlags.No nPublic |
BindingFlags.In stance);
FieldInfo fieldService =
fieldGridView.F ieldType.GetFie ld("serviceProv ider",
BindingFlags.No nPublic | BindingFlags.In stance);
fieldService.Se tValue(fieldGri dView.GetValue( this),
m_customPropert yGridService);
} // CustomPropertyG rid()
#endregion Constructor

#region -- Public Methods
/// <summary>Gets the custom property grid service.</summary>
public object GetServiceInter nal(Type service)
{
// Return custom service in place of internal service
if (service == typeof(IUIServi ce))
return m_customPropert yGridService;
else
return base.GetService (service);
} // GetServiceInter nal()
#endregion Public Methods

#region -- Overrides
/// <summary>Return s a custom property grid validation
service.</summary>
protected override object GetService(Type service)
{
// Return the custom property grid service in place of the
interal
return GetServiceInter nal(service);
} // GetService()
#endregion Overrides
} // Custom Property Grid

public class CustomPropertyG ridService : IServiceProvide r,
IUIService
{
#region -- Members
private CustomPropertyG rid m_propertyGrid = null; // Service
Owner
#endregion Members

#region -- Constructor
/// <summary>Create s a new custom property grid service.</
summary>
/// <param name="propertyG rid">Owner</param>
public CustomPropertyG ridService(Cust omPropertyGrid
propertyGrid)
{
// Set the owner
m_propertyGrid = propertyGrid;
} // CustomPropertyG ridService()
#endregion Constructor

#region -- IServiceProvide r Implementation
/// <summary>Gets the custom property grid service.</summary>
public object GetService(Type service)
{
// Return the custom property grid's service
return m_propertyGrid. GetServiceInter nal(service);
} // GetService()
#endregion IServiceProvide r Implementation

#region -- IUIService Implementation
/// <summary>Show s a custom error dialog in place of the
internal service's error dialog.</summary>
public DialogResult ShowDialog(Form form)
{
// Cancel invalid value
return DialogResult.Ca ncel;
} // ShowDialog()

public IDictionary Styles { get { return null; } }

public bool CanShowComponen tEditor(object component) { return
true; }

public IWin32Window GetDialogOwnerW indow() { return null; }

public void SetUIDirty() { }

public bool ShowComponentEd itor(object component, IWin32Window
parent) { return true; }

public void ShowMessage(str ing message) { }

public void ShowMessage(str ing message, string caption) { }

public DialogResult ShowMessage(str ing message, string
caption, MessageBoxButto ns buttons) { return DialogResult.OK ; }

public bool ShowToolWindow( Guid toolWindow) { return false; }

public void ShowError(strin g message) { }

public void ShowError(Excep tion ex) { }

public void ShowError(Excep tion ex, string message) { }
#endregion IUIService Implementation
} // Custom Property Grid Service
}

Any help will be appreciated.
Thanks,
Aug 22 '08 #1
1 4378
That code is a: incomplete, and b: too long to really answer. In
particular, it doesn't show anything relating to the collection
handling (nor UITypeEditor, etc).

Writing a PropertyGrid is not trivial; there are a few available (some
free, some to buy) that might be a better option than writing your
own.

Marc
Aug 23 '08 #2

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

Similar topics

2
2748
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx. The problem is the article is in VisualBasic. I already get the collection to be recognized as a Data Source by the IDE. It populated the DataGrid correctly from the fields on the items object of the collection, but I can't get the DataGrid to...
22
6097
by: James Cane | last post by:
Here's an interesting problem that someone might have an answer to... Some time ago, I wrote a set of utility classes which wrap up the custom row source function needed to add arbitrary items to a combo or listbox. It all works nicely and allows me to do things such as sorting by clicking on column headings. Recently, all the machines here were upgraded to Access XP from 97 and I thought it might be time to take advantage of the new...
2
3193
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/creatingcustomcolumns.asp The problem I am having is that the data in the custom datagridcolumn is not saved to viewstate and after postback, the column does not contain data.
0
2995
by: Adam J. Schaff | last post by:
Hello. I have a custom collection that implements IBindingList (allownew and allowremove are both true). I have bound it to a datagrid. I have add and remove buttons on the screen. I want to implement those buttons, but I'm not sure what the code should look like. I tried what I thought was obvious code: myCollection.AddNew() and
6
1872
by: Altman | last post by:
I would like to use an indexed property to access my private array of user controls. If I don't use an indexed property, the property will show up in my Properties Window during development. Is there a way to get this to show up in the properties window?
2
2441
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just fine. However, when attempting to assing default values as designtime in the propertygrid, nothing is working on the class object. I know that I am doing it wrong, any ideas what it is? Thanks in advance
0
3261
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design time. If I type the code in the aspx manually it does get parsed correctly though. This is an example of the aspx code that gets parsed correctly. For some reason, if I changed update the Tab property of the control through the GUI at design...
2
4224
by: R.A.F. | last post by:
Hi, I have a custom control in which i have a collection property named "Columns". this collection property add/remove column objects. in my Column class i have a property named Alignment which use a custom property editor. when this property editor is not linked to this property,
6
1878
by: tshad | last post by:
I was looking at a page that showed how to set up a custom event and it seems to work ok. But I am not sure how I would use it. How would I subscribe to it. There is actual action (such as pressing a button or changing text in a textbox). It gets set up and on the user control on my web page I can see the event from intellisense. So it seems to be set up, but I am trying to get an easy example of how I would now use this event. ...
0
8705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8623
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9196
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9054
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8896
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2362
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.