473,769 Members | 7,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with the filtering of a property grid

Hello.

I created a designer in c#. Everything is working excepted the
property grid.

I want to show only the properties I added. So I created a class which
inherits of a button. And I added properties.

But I want to filter the base properties. So to do this, I inherit my
class from ICustomTypeDesc riptor.

In the function getProperties, I filter. And I can show only my
properties. But on my host designer, the text of my button and the
position disappeared.

I mean when I add my custom button without filtering. I see it normal.
And if I filter, the text and position are removed. So it appears in
the left corner and I can't move it.

How can I fix the problem?

Thank you.
Jun 27 '08 #1
8 3003
Can I double check? It sounds like you are hosting a PropertyGrid in
your app, and want to filter the propeties that appear inside your app,
while leaving the regular VS IDE "as is" - correct?

You can use the BrowsableAttrib utes property to specify a filter based
on attributes; by default, it uses:
new Attribute[] {BrowsableAttri bute(true)}
Which hides properties with BrowsableAttrib ute(false) - but you can
specify your own. Alternatively, you can implement your own PropertyTab
(remove the default one, add yours instead) - and simply override
GetProperties in PropertyTab; that way you have complete control.

Marc
Jun 27 '08 #2
And here's an example of both approaches...

using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Drawing;
using System.Windows. Forms;
using System.Windows. Forms.Design;

public class Foo
{
[MyAttribute]
public int BrowseNotSetWit hCustom {get;set;}
[Browsable(true)]
public int BrowseTrueNoCus tom {get;set;}
[Browsable(false ), MyAttribute]
public int BrowseFalseWith Custom {get;set;}
}

class MyAttribute : Attribute {}
static class Program
{
static void Main()
{
// have 3 grids; one default, one using custom
// attributes, one using custom tab
Foo foo = new Foo();
Application.Ena bleVisualStyles ();
PropertyGrid customGrid = new PropertyGrid
{
Left = 400,
Height = 400,
SelectedObject = foo,
BrowsableAttrib utes = new AttributeCollec tion()
};
customGrid.Prop ertyTabs.AddTab Type(typeof(MyT ab),
PropertyTabScop e.Static);
Application.Run (
new Form {
Width = 800,
Height = 450,
Controls = {
new PropertyGrid {
Left = 0,
Height = 400,
SelectedObject = foo
},
new PropertyGrid {
Left = 200,
Height = 400,
BrowsableAttrib utes = new AttributeCollec tion(
new MyAttribute()),
SelectedObject = foo
},
customGrid
}
}
);
}
}
public class MyTab : PropertyTab
{
public MyTab() {

}
public override System.Drawing. Bitmap Bitmap
{
get
{
return SystemIcons.Shi eld.ToBitmap();
}
}
public override bool CanExtend(objec t extendee)
{
return true;
}
public override PropertyDescrip torCollection
GetProperties(I TypeDescriptorC ontext context, object component,
Attribute[] attributes)
{
return GetProperties(c omponent, attributes);
}
public override PropertyDescrip torCollection GetProperties(o bject
component)
{
return GetProperties(c omponent, null);
}
public override PropertyDescrip torCollection GetProperties(o bject
component, Attribute[] attributes)
{
PropertyDescrip torCollection props =
TypeDescriptor. GetProperties(c omponent, attributes);
List<PropertyDe scriptorlist = new
List<PropertyDe scriptor>(props .Count);
foreach (PropertyDescri ptor prop in props)
{
if (prop.Name == "BrowseTrueNoCu stom") continue; // skip
list.Add(prop);
}
return new PropertyDescrip torCollection(l ist.ToArray());
}
public override string TabName
{
get { return "Mwahahah"; }
}
}
Jun 27 '08 #3
Thank you marc for your sample. But I can't compile it. I have VS2005

Could you give me an example which works with VS2005. Moreover, I
didn't understand, why I need to use three propertygrid.

Could you please explain me? Thank you
Jun 27 '08 #4
Ok well I worked a lot and I fixed the problem. Thanks a lot Marc.

Just a question. When I want to add a component to my host designer, I
would like to show the picture of my component as visual. Do you how
can I do that?

Thanks

Jun 27 '08 #5
Ok well I worked on my problem. And it is fine. i fixed the problem.
Thanks a lot.

But i have an other question. Do you know how can I show the picture
of the component I want to add to my host designer when I chose it in
the toolbox?

Thanks alot for your help.
Jun 27 '08 #6
But I can't compile it. I have VS2005
From your later post, it sounds like this is sorted - but please let
me know if it isn't: I can port it to C# 2 easily enough (it just
takes more typing...)
I didn't understand, why I need to use three propertygrid.
The three grids was merely to show the difference between the standard
behaviour, the behavior with a different attribute filter, and the
behavior with a custom tab.

Marc
Jun 27 '08 #7
Just a question. When I want to add a component to my host designer, I
would like to show the picture of my component as visual. Do you how
can I do that?
Can you be more specific? Where do you want it to be graphic? For
example, you can specify a toolbox bitmap (from a file or a resource
inside the assembly) with ToolboxBitmapAt tribute:
http://msdn.microsoft.com/en-us/libr...attribute.aspx

Or if you mean inside the property-grid (like how images, colours etc
hav a preview), this is the job of a UITypeEditor.

Marc
Jun 27 '08 #8

When I choose a component in my toolbox to add it to my designer, I
have a cross as cursor. And I would like to show the picture of the
component near the cursor as visual studio is doing.

Do you have an idea?

I have a last question. Sorry for my bad knowledge. I have firefox and
I installed piclens. The user interface is really cool and I would
like to create the same or closer. Do you think I can create it with
Visual Studio 2005 desktop application? Maybe I can use DirectX. Do
you have an other idea?

An other solution will be to se csharp 3.0. What could you advice me?

Thanks a lot. I really apreciate your help.
Jun 27 '08 #9

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

Similar topics

7
6814
by: Amar | last post by:
I am trying to connect to my college LDAP directory using ASP.NET. This LDap does not have security as it returns only user demographic information. i do not need to bind with a username or credentials. What i am trying to do is, i am trying to look up all the information for the user with user id 'testuser'. The following is the Vb.net code for my aspx page: Dim oRoot As DirectoryEntry = New...
0
6475
by: CSDunn | last post by:
Hello, I have a problem with field filtering between an Access 2000 Project form (the application is called CELDT), and the report that shows the results of the filter. Both the form and the report are based on the same View addressed in the Record Source of both as 'dbo.CLMain_vw'. The View resides in a SQL Server 2000 database. There are two different problems I am having with filtering: The first involves filtering in the form by date...
2
3982
by: Mevar81 | last post by:
Hi to everybody.I have a problem with the PropertyGrid control.I want to display not all the properties of a generic Control(Button,TextBox,ComboBox,ecc.).In general I don't want to display only one category(Appearance, Behavior,ecc.) but I want to chose directly which properties to show.I've read that I can use the SelectedObjects to put an array of object with some properties in common with the SelectedObject,and only properties in...
3
993
by: asad | last post by:
Hello, i want to filter my records in ASP.NET pls tell me how can i do it thanks
7
14819
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I want to look at that data and filter it based on what is in it. I know that this could have been done with data sets and data views in asp.net 1.1 but how is this done now in asp.net 2.0?
5
1641
by: DBC User | last post by:
I have a data set which has a data table. This dataset is set as a datasource for a display grid. Before I assign the data set to data grid, I would like to elliminate some rows from the data table. How can I do this? I saw an example where I can identify the table and then apply the select on the table. Which returns the data rows. Is there a way I can remove the rows without doing this 2 step process of obtaining the data row and then...
2
2220
by: kevinpond | last post by:
I have a Gridview displaying the results of a stored procedure. The stored procedure is constantly changing so the columns displayed in the data grid are constantly changing. I'd like to give users the ability to filter by the value of any column. This is easily done using the FilterExpression property of the DataSource. However, prior to creating the filter expression, I need to know if the column they wish to filter contains text or...
0
1678
by: sjoshi | last post by:
Hello All I'm trying to use a filter with collectiong derived off BindingList and I see that if I use the foreach way of adding and checking the item then I get instant feedback on the grid. If I use a Predicate to filter using FindAll then I see my grid refreshed only when I change the selected row. My class is defined as this ....
0
2003
by: Lyn | last post by:
I have a problem using the form .Filter and .FilterOn properties which causes Access to crash (as detailed in a separate post). The form operates in continuous mode, displaying matching records from a file based on a search criterion. This basic functionality works just fine. I decided to allow the user to narrow down the output by providing some extra controls to allow the user to filter the recordset via the .Filter form property. ...
0
9589
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
10049
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
9865
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
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
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
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.