datagridview的常见属性及实现代码;
多多益善,最好详细的

解决方案 »

  1.   

    http://msdn.microsoft.com/zh-tw/default.aspx
    然後在裏面搜索datagridview,你就能找到你要的東西了
      

  2.   

    知道一个datasource足够,剩下的查msdn就行了
      

  3.   

    备注
    DataGridView 控件提供用来显示数据的可自定义表。使用 DataGridView 类,可以通过使用 DefaultCellStyle、ColumnHeadersDefaultCellStyle、CellBorderStyle 和 GridColor 等属性对单元格、行、列和边框进行自定义。有关更多信息,请参见 Windows 窗体 DataGridView 控件中的基本格式设置和样式设置。可以使用 DataGridView 控件来显示有基础数据源或没有基础数据源的数据。如果没有指定数据源,可以创建包含数据的列和行,并将它们直接添加到 DataGridView。或者,可以设置 DataSource 和 DataMember 属性,以便将 DataGridView 绑定到数据源,并自动用数据填充该控件。有关更多信息,请参见在 Windows 窗体 DataGridView 控件中显示数据。在处理大量数据时,可以将 VirtualMode 属性设置为 true,以便显示可用数据的子集。虚拟模式要求实现用来填充 DataGridView 控件的数据缓存。有关更多信息,请参见 Windows 窗体 DataGridView 控件中的数据显示模式。有关 DataGridView 控件中可用功能的其他信息,请参见 DataGridView 控件(Windows 窗体)。 虽然 DataGridView 控件替代了以前版本的 DataGrid 控件并增加了功能,但是为了实现向后兼容并考虑到将来的使用(如果您选择的话),仍然保留了 DataGrid 控件。有关更多信息,请参见 Windows 窗体 DataGridView 控件和 DataGrid 控件之间的区别。示例
    下面的代码示例演示如何初始化一个未绑定的 DataGridView。要运行此示例,请将下面的代码粘贴到一个窗体中,该窗体包含一个名为 dataGridView1 的 DataGridView 以及三个名称分别为 addNewRowButton、deleteRowButton 和 ledgerStyleButton 的按钮。从窗体的构造函数或 Load 事件处理程序中调用 SetUpDataGridView 和 PopulateDataGridView 方法。确保所有事件都与其事件处理程序关联。
    private void ledgerStyleButton_Click(object sender, System.EventArgs e)
    {
        // Create a new cell style.
        DataGridViewCellStyle style = new DataGridViewCellStyle();
        {
            style.BackColor = Color.Beige;
            style.ForeColor = Color.Brown;
            style.Font = new Font("Verdana", 8);
        }    // Apply the style as the default cell style.
        dataGridView1.AlternatingRowsDefaultCellStyle = style;
        ledgerStyleButton.Enabled = false;
    }private void SetUpDataGridView()
    {
        this.Controls.Add(dataGridView1);
        dataGridView1.ColumnCount = 5;
        DataGridViewCellStyle style = 
            dataGridView1.ColumnHeadersDefaultCellStyle;
        style.BackColor = Color.Navy;
        style.ForeColor = Color.White;
        style.Font = new Font(dataGridView1.Font, FontStyle.Bold);    dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;
        dataGridView1.Name = "dataGridView1";
        dataGridView1.Location = new Point(8, 8);
        dataGridView1.Size = new Size(500, 300);
        dataGridView1.AutoSizeRowsMode = 
            DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
        dataGridView1.ColumnHeadersBorderStyle = 
            DataGridViewHeaderBorderStyle.Raised;
        dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.Single;
        dataGridView1.GridColor = SystemColors.ActiveBorder;
        dataGridView1.RowHeadersVisible = false;    dataGridView1.Columns[0].Name = "Release Date";
        dataGridView1.Columns[1].Name = "Track";
        dataGridView1.Columns[1].DefaultCellStyle.Alignment = 
            DataGridViewContentAlignment.MiddleCenter;
        dataGridView1.Columns[2].Name = "Title";
        dataGridView1.Columns[3].Name = "Artist";
        dataGridView1.Columns[4].Name = "Album";    // Make the font italic for row four.
        dataGridView1.Columns[4].DefaultCellStyle.Font = new Font(DataGridView.DefaultFont, FontStyle.Italic);    dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
        dataGridView1.MultiSelect = false;    dataGridView1.BackgroundColor = Color.Honeydew;    dataGridView1.Dock = DockStyle.Fill;    dataGridView1.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting);
        dataGridView1.CellParsing += new DataGridViewCellParsingEventHandler(dataGridView1_CellParsing);
        addNewRowButton.Click += new EventHandler(addNewRowButton_Click);
        deleteRowButton.Click += new EventHandler(deleteRowButton_Click);
        ledgerStyleButton.Click += new EventHandler(ledgerStyleButton_Click);
        dataGridView1.CellValidating += new DataGridViewCellValidatingEventHandler(dataGridView1_CellValidating);}private void PopulateDataGridView()
    {    // Create the string array for each row of data.
        string[] row0 = { "11/22/1968", "29", "Revolution 9", "Beatles", "The Beatles [White Album]" };
        string[] row1 = { "4/4/1960", "6", "Fools Rush In", "Frank Sinatra", "Nice 'N' Easy" };
        string[] row2 = { "11/11/1971", "1", "One of These Days", "Pink Floyd", "Meddle" };
        string[] row3 = { "4/4/1988", "7", "Where Is My Mind?", "Pixies", "Surfer Rosa" };
        string[] row4 = { "5/1981", "9", "Can't Find My Mind", "Cramps", "Psychedelic Jungle" };
        string[] row5 = { "6/10/2003", "13", "Scatterbrain. (As Dead As Leaves.)", "Radiohead", "Hail to the Thief" };
        string[] row6 = { "6/30/1992", "3", "Dress", "P J Harvey", "Dry" };    // Add a row for each string array.
        {
            DataGridViewRowCollection rows = this.dataGridView1.Rows;
            rows.Add(row0);
            rows.Add(row1);
            rows.Add(row2);
            rows.Add(row3);
            rows.Add(row4);
            rows.Add(row5);
            rows.Add(row6);
        }    // Change the order the columns are displayed.
        {
            DataGridViewColumnCollection columns = this.dataGridView1.Columns;
            columns[0].DisplayIndex = 3;
            columns[1].DisplayIndex = 4;
            columns[2].DisplayIndex = 0;
            columns[3].DisplayIndex = 1;
            columns[4].DisplayIndex = 2;
        }
    }
      

  4.   

    msdn最全面,操作
    参考
      

  5.   

    LZ 应该是学习C#的新手吧,建议多查看MSDN, 只要输入DataGridView就可以查看它的属性,方法,事件随时可以查阅
    另外 楼主 可以安装VS是附带安装MSDN 帮助文档 是在不行就网络版的MSDN的也行
      

  6.   

    LZ 应该是学习C#的新手吧,建议多查看MSDN, 只要输入DataGridView就可以查看它的属性,方法,事件随时可以查阅
    另外 楼主 可以安装VS是附带安装MSDN 帮助文档 是在不行就网络版的MSDN的也行
      

  7.   

    LZ 应该是学习C#的新手吧,建议多查看MSDN, 只要输入DataGridView就可以查看它的属性,方法,事件随时可以查阅
    另外 楼主 可以安装VS是附带安装MSDN 帮助文档 是在不行就网络版的MSDN的也行
      

  8.   

    MSDN,上面有实例的,照着做一两个例子就会了
      

  9.   

    要了解一个控件的具体属性,msdn无疑是最好的老师
      

  10.   

    MSDN .net framework 下的datagridview类,打开就看见了,属性和方法的列表都可见,楼主要多多利用一资源,
      

  11.   

    各位大虾!
    dataGridView的每个单元格,可以显示图片吗?
      

  12.   

    看看HELP文件吧,多看见次就常见了
      

  13.   

    MSDN上有我也知道但谁有列出的常见的总结,谁要再说这,一分不给!!!!!!