Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Common methods for different objects
Message
De
21/05/2009 13:58:09
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01400964
Message ID:
01401381
Vues:
64
This message has been marked as the solution to the initial question of the thread.
>>>Can you please outline exactly what did you do step by step for dummies? I probably did something wrong yesterday, but it was very depressing to have it coded once, then re-coded again.
>>
>>I created a sub-classed DataGrid:
    class SomeGrid : System.Windows.Forms.DataGrid
>>    {
>>    }
and dragged it from the toolbox onto a form. Here's the generated code:
namespace SmartDeviceProject1
>>{
>>    partial class Form1
>>    {
>>        /// <summary>
>>        /// Required designer variable.
>>        /// </summary>
>>        private System.ComponentModel.IContainer components = null;
>>        private System.Windows.Forms.MainMenu mainMenu1;
>>
>>        /// <summary>
>>        /// Clean up any resources being used.
>>        /// </summary>
>>        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
>>        protected override void Dispose(bool disposing)
>>        {
>>            if (disposing && (components != null))
>>            {
>>                components.Dispose();
>>            }
>>            base.Dispose(disposing);
>>        }
>>
>>        #region Windows Form Designer generated code
>>
>>        /// <summary>
>>        /// Required method for Designer support - do not modify
>>        /// the contents of this method with the code editor.
>>        /// </summary>
>>        private void InitializeComponent()
>>        {
>>            this.mainMenu1 = new System.Windows.Forms.MainMenu();
>>            this.someGrid1 = new SmartDeviceProject1.SomeGrid();
>>            ((System.ComponentModel.ISupportInitialize)(this.someGrid1)).BeginInit();
>>            this.SuspendLayout();
>>            // 
>>            // someGrid1
>>            // 
>>            this.someGrid1.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
>>            this.someGrid1.Location = new System.Drawing.Point(28, 41);
>>            this.someGrid1.Name = "someGrid1";
>>            this.someGrid1.Size = new System.Drawing.Size(174, 166);
>>            this.someGrid1.TabIndex = 1;
>>            // 
>>            // Form1
>>            // 
>>            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
>>            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
>>            this.AutoScroll = true;
>>            this.ClientSize = new System.Drawing.Size(240, 268);
>>            this.Controls.Add(this.someGrid1);
>>            this.Menu = this.mainMenu1;
>>            this.Name = "Form1";
>>            this.Text = "Form1";
>>            ((System.ComponentModel.ISupportInitialize)(this.someGrid1)).EndInit();
>>            this.ResumeLayout(false);
>>
>>        }
>>
>>        #endregion
>>
>>        private SomeGrid someGrid1;
>>    }
>>}
Compiles fine...
>
>Does it run fine? I got an error in run-time, not in the compile time. Also what type of the project did you chose for your class?
OK. I got the error - so just implement the ISupportInitialize methods in the base class:
class SomeGrid : System.Windows.Forms.DataGrid ,System.ComponentModel.ISupportInitialize
    {
        public void BeginInit(){}
        public void EndInit(){}
    }
Unless something (like another thread) is trying to access the form during initialization (unlikely) this should work fine.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform