2024年终活动

DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

DevExpress XtraGrid网格控件示例八:在GridView中编辑合并后的单元格

来源:本站原创   发布时间:2012-11-05   浏览:5946次

在默认情况下,GridView 不支持编辑合并后的单元格。本示例主要展示如何创建一个支持编辑合并单元格的自定义GridView。

VB.NET


Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Namespace EditMergedCells
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
Dim dt As DataTable
dt = New DataTable()
dt.Columns.Add("Column1")
dt.Columns.Add("Column2")
Dim dr As DataRow = dt.NewRow()
dr(0) = "Value1"
dr(1) = "Value2"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = "Value1"
dr(1) = "Value3"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = "Value1"
dr(1) = "Value5"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = "Value4"
dr(1) = "Value5"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = "Value4"
dr(1) = "Value5"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = "Value4"
dr(1) = "Value5"
dt.Rows.Add(dr)
myGridControl1.DataSource = dt
gridControl1.DataSource = dt
End Sub
End Class
End Namespace


C#


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace EditMergedCells
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
DataTable dt;
dt = new DataTable();
dt.Columns.Add("Column1");
dt.Columns.Add("Column2");
DataRow dr = dt.NewRow();
dr[0] = "Value1";
dr[1] = "Value2";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "Value1";
dr[1] = "Value3";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "Value1";
dr[1] = "Value5";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "Value4";
dr[1] = "Value5";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "Value4";
dr[1] = "Value5";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "Value4";
dr[1] = "Value5";
dt.Rows.Add(dr);
myGridControl1.DataSource = dt;
gridControl1.DataSource = dt;
}
}
}


本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/402.html
扫码咨询
电话咨询
023-68661681
返回
顶部