the Design View of Datagridview in visual studio
sorry that i have to put this thread in Visual C# General since i cannot find an feasible category for this thread.
I have suffered for a long time, i have a datagridview control in a windows form, it was supposed to be a Property of the class, but everytime i switch to Design View of the form, the definition of datagridview is automatically moved into the InitializeComponent() method as a local variable rather than a property of the form, and i have to cut the code and paste into the property declaration part.....
please help...
i got mad with that....
thanks a million
renjian
simply drag a datagridview control from the toolbox on the left side of Visual Studio. the datagridview was declared as a property of the form(that was what i want), but next time you switch to design view, the definination just went away...
thanks
here is the code snippet:
Before:
partial class MyForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <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()
{
// code here was deleted
}
#endregion
System.Windows.Forms.DataGridView dgvProduct;
}
after :
partial class MyForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <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()
{
System.Windows.Forms.DataGridView dgvProduct = new System.Windows.Forms.DataGridView();
// code here was deleted
}
#endregion
}