Click here to Skip to main content
15,891,674 members
Home / Discussions / C#
   

C#

 
AnswerRe: Really I need Help Pin
Ed.Poore3-May-06 11:20
Ed.Poore3-May-06 11:20 
AnswerRe: Really I need Help Pin
Ravi Bhavnani3-May-06 13:00
professionalRavi Bhavnani3-May-06 13:00 
QuestionAdding new row in UltraWinGrid in Windows Form Pin
Neel073-May-06 7:16
Neel073-May-06 7:16 
QuestionEvents Pin
Smith#3-May-06 6:15
Smith#3-May-06 6:15 
QuestionHow to update ComboBox/ListBox bound to ArrayList? Pin
therealmccoy3-May-06 6:04
therealmccoy3-May-06 6:04 
AnswerRe: How to update ComboBox/ListBox bound to ArrayList? Pin
Travis D. Mathison3-May-06 8:22
Travis D. Mathison3-May-06 8:22 
GeneralRe: How to update ComboBox/ListBox bound to ArrayList? Pin
therealmccoy3-May-06 11:05
therealmccoy3-May-06 11:05 
QuestionProblems exposing attributes in a DataGridView Pin
Pink Floyd3-May-06 6:01
Pink Floyd3-May-06 6:01 
Hi and THANKS a lot in advance.

I'm in a big urge to get this done, so please, any help is greatly appreciated.

I'll use a simplified scenario of my case, but the error happens the same. I'm creating a new User Control, I add a DataGridView to it, that's the only control in it. I then create a public property called "Columns" to expose the DataGridView Columns property so I can access the property from the Designer Editor. I do that this way:

namespace WindowsApplication3
{
public partial class myUC : UserControl
{
public myUC()
{
InitializeComponent();
}

[Editor("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
[MergableProperty(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DataGridViewColumnCollection Columns
{
get { return this.dataGridView1.Columns; }
}
}
}


I took all that Attributes code from the System.Windows.Forms.DataGridView metadata, just like the Columns property appears in it.

Then, I add a Windows Forms item to my application and drag&drop one MyUC control from the toolbox into it. Then I click the MyUC and go to its properties page to modify the Columns properties just like with an ordinary DataGridView. The property is there but when clicking on its "..." button to open de Edit Columns Dialog I get the mentioned error. Something like this:

"Unable to cast object of type 'WindowsApplication3.myUC" to type "System.Windows.Forms.DataGridView".

After posting in other forums and threads, a guy came with a suggestion to use Attribute Redirection to accomplish the goal. So, I included this:

[AttributeProvider( "System.Windows.Forms.Design.DataGridView", "Columns" )]
public DataGridViewColumnCollection Columns
{
get { return this.dataGridView1.Columns; }
}

(Afert adding that, remove the [Editor (...)] attribute line)

This partially solves the first problem. Now, the Columns Editor finally appears, BUT, Two things happen now:
1. New columns can't be added using the editor. A error is shown when trying to add new columns.

2. Even worse, no changes are saved to the control. As soon as you build the project, all the changes are gone. For instance, if the Header Text of the columns is changed, and then a build is done, the Header text changes are lost. No data is being persisted.
I really really need the Columns property to be accesible in Design Time this way. I don't know how to work this out.

I get this error and problems with an almost blank project. Just add a User Control Item, put a DataGridView into it. Add the code above to make the Columns property visible and then try to access the property in the Property page.

I think what I'm trying to do is quite simple, so I'm wondering what the problem is, and how to work it out.

Thank you so much in advance.

F.

PD: I'm using the shipped VS.NET 2005.

Questionsending message from tcp socket to web service Pin
pg663-May-06 5:55
pg663-May-06 5:55 
QuestionGeneric problem seeking Generic help Pin
_awatts3-May-06 5:28
_awatts3-May-06 5:28 
AnswerRe: Generic problem seeking Generic help Pin
Guffa3-May-06 6:05
Guffa3-May-06 6:05 
Question.NET Remoting problem Pin
Kasdoffe3-May-06 5:01
Kasdoffe3-May-06 5:01 
QuestionVS 2003 Build Comment Web Pages problem Pin
For_IT3-May-06 4:32
For_IT3-May-06 4:32 
QuestionBest way to iterate through all folders and subfolders from parent folder? Pin
Subterranean3-May-06 4:24
Subterranean3-May-06 4:24 
AnswerRe: Best way to iterate through all folders and subfolders from parent folder? Pin
Ravi Bhavnani3-May-06 4:59
professionalRavi Bhavnani3-May-06 4:59 
QuestionReference/tutorial material for using MSHTML from C#? Pin
cweeks786813-May-06 4:21
cweeks786813-May-06 4:21 
QuestionHow to use maps in C# Desktop Application Pin
Jax_qqq3-May-06 4:04
Jax_qqq3-May-06 4:04 
AnswerRe: How to use maps in C# Desktop Application Pin
Judah Gabriel Himango3-May-06 4:18
sponsorJudah Gabriel Himango3-May-06 4:18 
AnswerRe: How to use maps in C# Desktop Application Pin
Phil C6-May-06 10:40
Phil C6-May-06 10:40 
GeneralRe: How to use maps in C# Desktop Application Pin
Jax_qqq7-May-06 18:35
Jax_qqq7-May-06 18:35 
Questionweb serivce at runtime Pin
myousufq3-May-06 3:43
myousufq3-May-06 3:43 
QuestionChanging tab pages - item having focus Pin
oracleConvert3-May-06 3:18
oracleConvert3-May-06 3:18 
QuestionProperty Grid Pin
zee13-May-06 3:17
zee13-May-06 3:17 
AnswerRe: Property Grid Pin
zee15-May-06 22:04
zee15-May-06 22:04 
QuestionNDOC Error Pin
For_IT3-May-06 3:17
For_IT3-May-06 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.