Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here is what i want to do:



object DataSource_m;

public object DataSource
{
get
{

return DataSource_m;

}

set
{

DataSource_m = value;

}

}



this property is for a Custom Control.

Now When I add this Control in a form and go to its property window I get A property as DataSource as expected, in the designer mode.

when i click the DataSource Property to attach a databse, i dont get the "Add Project DataSource" option in the property, which we usually get in the DataGridView Control's DataSource Property......

what attributes should i use to get That.

SCREENSHOT:

http://adieu.webs.com/Images/Untitled.bmp
Posted
Updated 30-Jun-10 8:13am
v2

Hey there,

There is a walk through here[^] on MSDN that you will find helpful.

The key thing you're likely missing is adding the attributes required to pick up those properties.

Cheers.
 
Share this answer
 
Comments
OWDARO 30-Jun-10 13:26pm    
thank you very much for it my friend but i even tried the attributes.
that also doesn't work.....
well i will see ur link too now and will tell u whether i was successful or not...
thank u once again
you can simply do this:

C#
using System.ComponentModel;
//more using statements

public class YourClass:SomeControl
{
    object DataSource_m;

    
    [AttributeProvider(typeof(IListSource)), RefreshProperties(RefreshProperties.Repaint)]
    public object DataSource
    {
        get{ return DataSource_m;}
        set{ DataSource_m = value;}
    }

}


[Update: you'll probably also want the RefreshProperties Attribute]

[Response to comment]
This is my class:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
namespace TestFormCSharp
{
    class MyDataSourceClass:Control
    {
        object dataSource_m;
        [AttributeProvider(typeof(IListSource)), RefreshProperties(RefreshProperties.Repaint)]
        public object DataSource
        {
            get { return dataSource_m; }
            set { dataSource_m = value; }
        }
    }
}


and this is what I get:
http://yfrog.com/bfscreenshotdatasourcej[^]

If you're not getting the same, then you'd have to show us more of your class declaration and/or tell us what version of VS you're using...if you're using VS;
 
Share this answer
 
v6
Comments
OWDARO 1-Jul-10 12:04pm    
Thank You All For Ur Replies....But It Is Still Not Working
This Is What I Get EveryTime....

Screen Shot
http://adieu.webs.com/Images/Untitled2.png

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900