Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problems with AddRange and DataGridView
Message
De
03/02/2009 06:11:56
 
 
À
31/01/2009 18:16:44
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01378089
Message ID:
01378932
Vues:
15
>Hi Pete,
>
>Well, first of all, you have to be careful about changing designer-generated code. It will most likely get overwritten.
>
>Next, is your error about converting "MyDataGridViewTextBoxColumn to MyDataGridViewColumn" or "MyDataGridViewTextBoxColumn to DataGridViewColumn "?
>
>What have you sub-classed your MyDataGridViewTextBoxColumn from?
>
>~~Bonnie
>
>
>
>
>>Hi All, I recently subclassed some of the commonly used DataGridView (dgv from here on ) controls and duly modifed my app code to utilise them, all went as expected until I got to adding the columns as an array of DataGridViewColumns.
>>
>>The form designer generated code looked like this
>>
>>
>>this.dgvBlocks.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { column1,column2 })
>>
>>
>>So, I duly changed System.Windows.Forms.DataGridViewColumn[] to my subclass , I then received this compiler error
>>
>>
>>cannot implicitly convert type MyDataGridViewTextBoxColumn to MyDataGridViewColumn 
>>
>>
>>But if I use the designer code it works ! Any ideas ?

You'd also need to change the definitions for column1 and column2 :
this.Column1 = new MyDataGridViewTextBoxColumn();
this.Column2 = new MyDataGridViewTextBoxColumn();
But, as Bonnie says there's every chance that these changes won't persist becasue the designer code will be regenerated....
Regards,
Viv
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform