请求帮助,关于DataGrid,谢谢各位大哥

jackbaby 2005-10-20 05:10:02
我们公司要求做个能控制的多表头DataGrid
| 表头一 | 表头二 |
|一 | 二 |一 | 二 |

这样的类似的东西,我找了两天了,找到关于asp.net方面的有一些,但是那位大哥有c/s下面的列子吗??
我们经理要求我重写DataGrid,来描叙,要怎么写哈??思路是个什么样的哈??各位大哥能帮帮忙吗????谢谢了
...全文
108 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackbaby 2005-10-21
  • 打赏
  • 举报
回复
谢谢各位大哥了,找到一个SourceGrid2的开源,有个小例子,好像有些帮助,不敢独享

http://www.devage.com/SourceGrid/SourceGrid2_Source_2_2_0_0_VS2003.zip


谢谢各位大哥了
qpl007 2005-10-20
  • 打赏
  • 举报
回复
楼主说的是 WinForm 上的东东吧,WebForm 上可以通过操作表格来变相的操作DataGrid,但WinForm 就没那么简单了吧。

在 DataGrid(WinForm的) 内部,有专门的类(DataGridCaption)类来维护、呈现和管理表头。
但遗憾的是,微软没有将 DataGridCaption 设计成 public 的:
internal class DataGridCaption
{
internal void Paint(Graphics g, Rectangle bounds, bool alignRight)
{
//这里就是 DataGrid 画表头的地方
}
}
这意味着我们如果需要重绘表头,需要自己完成DataGridCaption类,并在其中完成复杂的表头绘画操作。

复杂度可想而知。

楼主如果事件充裕的话,可以当兴趣研究研究,但如果在做项目的话,还是采用其他方法吧,如:将DataGrid表头设为固定并不显示,在用 Label 模拟表头
mathsword 2005-10-20
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/4150/4150195.xml?temp=.6106226
http://www.pconline.com.cn/pcedu/empolder/net/0411/488314.html
winterice 2005-10-20
  • 打赏
  • 举报
回复
变通方法:采用table来实现表头,并将每个列的宽度设置好,和datagrid中的列宽对应好
cansum396 2005-10-20
  • 打赏
  • 举报
回复
学习
qpl007 2005-10-20
  • 打赏
  • 举报
回复
不好意思,上面贴错了。 ^-^

如果真的要写DataGrid的话:只有继承自DataGrid,重写 OnPaint 方法
desailly 2005-10-20
  • 打赏
  • 举报
回复
顶``````
qpl007 2005-10-20
  • 打赏
  • 举报
回复
using System;
using System.Collections;
public class SamplesQueue {

public static void Main() {

// Creates and initializes a new Queue.
Queue myQ = new Queue();
myQ.Enqueue("Hello");
myQ.Enqueue("World");
myQ.Enqueue("!");

// Displays the properties and values of the Queue.
Console.WriteLine( "myQ" );
Console.WriteLine( "\tCount: {0}", myQ.Count );
Console.Write( "\tValues:" );
PrintValues( myQ );
}


public static void PrintValues( IEnumerable myCollection ) {
System.Collections.IEnumerator myEnumerator = myCollection.GetEnumerator();
while ( myEnumerator.MoveNext() )
Console.Write( "\t{0}", myEnumerator.Current );
Console.WriteLine();
}
}

/*
输出:

myQ
Count: 3
Values: Hello World !
*/

没问题啊
qpl007 2005-10-20
  • 打赏
  • 举报
回复
这个就复杂了,要重绘DataGrid,还涉及到表头的拖动等其他很多问题。

建议楼主采用其他变通的方式来处理
jeffwangxm 2005-10-20
  • 打赏
  • 举报
回复
没做过多表头的,帮顶,学习

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧