C#的多行表头,用TreeView实现,如图所示

本文介绍了如何使用 C# 的 TreeView 控件创建多行表头。通过引用网络资源并进行实践,作者成功实现了所需效果,并提供了数据绑定示例。此外,还提及了如何对多行表头进行颜色区分的方法。
摘要由CSDN通过智能技术生成

如图

根据网上资料,进行实操后,得到上图,觉得还是挺不错的,

 

namespace MultiColHeaderDgvTest
{
    partial class FrmTest
    {
        /// <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.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Node1");
            System.Windows.Forms.TreeNode treeNode1_1 = new System.Windows.Forms.TreeNode("Node1_1", new System.Windows.Forms.TreeNode[] {
            treeNode1});
            System.Windows.Forms.TreeNode treeNode1_2 = new System.Windows.Forms.TreeNode("treeNode1_2", new System.Windows.Forms.TreeNode[] {
            treeNode1_1 });
            System.Windows.Forms.TreeNode treeNode1_3 = new System.Windows.Forms.TreeNode("treeNode1_3", new System.Windows.Forms.TreeNode[] {
            treeNode1_2 });

            System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Node2");
            System.Windows.Forms.TreeNode treeNode2_1 = new System.Windows.Forms.TreeNode("treeNode2_1", new System.Windows.Forms.TreeNode[] {
            treeNode2});
            System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("treeNode3");
            System.Windows.Forms.TreeNode treeNode3_1 = new System.Windows.Forms.TreeNode("treeNode3_1", new System.Windows.Forms.TreeNode[] {
            treeNode3 });
            System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("treeNode4");
            System.Windows.Forms.TreeNode treeNode4_1 = new System.Windows.Forms.TreeNode("treeNode4_1", new System.Windows.Forms.TreeNode[] {
            treeNode4});
            System.Windows.Forms.TreeNode treeNode5 = new System.Windows.Forms.TreeNode("treeNode5");
            System.Windows.Forms.TreeNode treeNode5_1 = new System.Windows.Forms.TreeNode("treeNode5_1", new System.Windows.Forms.TreeNode[] {
            treeNode5});
            System.Windows.Forms.TreeNode treeNode6 = new System.Windows.Forms.TreeNode("treeNode6");
            System.Windows.Forms.TreeNode treeNode6_1 = new System.Windows.Forms.TreeNode("treeNode6_1", new System.Windows.Forms.TreeNode[] {
            treeNode6});
            System.Windows.Forms.TreeNode treeNode6_2 = new System.Windows.Forms.TreeNode("treeNode6_2", new System.Windows.Forms.TreeNode[] {
            treeNode6_1});
            System.Windows.Forms.TreeNode treeNode7 = new System.Windows.Forms.TreeNode("treeNode6");
            System.Windows.Forms.TreeNode 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值