重载DBGrid的目标是这样的.
如果有这样的一张表,
部门编号 个人编号 姓名
1 1 jjljlk
1 2 ajjal
1 3 aljflad
2 1 adjakd
2 2 adksklaj
显示出来时,是这样的
部门编号 个人编号 姓名
1 1 jjljlk
2 ajjal
3 aljflad
2 1 adjakd
2 adksklaj
查了一些资料,发现要重载OnDrawColumnCell(大概吧,我用的机子不能上网.).这个事件来自TCustomDBGrid.但是在TCustomDBGrid中只找到了FOnDrawColumnCell的声明,也找不到其实现.不过运气不错,找不了一个叫DefaultDrawColumnCell,知道在这个函数里有一个WriteText具体负责显示.但是就是没有找到有哪个地方使用到这个函数的.请指教.
如果有这样的一张表,
部门编号 个人编号 姓名
1 1 jjljlk
1 2 ajjal
1 3 aljflad
2 1 adjakd
2 2 adksklaj
显示出来时,是这样的
部门编号 个人编号 姓名
1 1 jjljlk
2 ajjal
3 aljflad
2 1 adjakd
2 adksklaj
查了一些资料,发现要重载OnDrawColumnCell(大概吧,我用的机子不能上网.).这个事件来自TCustomDBGrid.但是在TCustomDBGrid中只找到了FOnDrawColumnCell的声明,也找不到其实现.不过运气不错,找不了一个叫DefaultDrawColumnCell,知道在这个函数里有一个WriteText具体负责显示.但是就是没有找到有哪个地方使用到这个函数的.请指教.
解决方案 »
- Delphi内部不开新窗口打开一个选择“是”“否”窗口
- delphi 如何在access数据库中存取图像文件
- delphi 调用C# WebService的问题.
- 请问谁有leadtools V12这个 版本?
- Delphi:如何判断groupbox中所有的edit是否为空?
- (菜鸟问题)treeview的一个node用edittext以后怎么样获取修改后的text?
- 上哪找FORMULA ONE 5.0控件
- 如何通过query在Access数据库查找一个时间段的记录
- 国庆大送分,一个简单的问题,分不够再说
- 求教小问题
- 我使用了存储过程(SQL SERVER) 我想把存储过程中的错误反映到应用程序中 请问如何做
- 如何制作像word如视图-工具中表格与边框的窗口,能停留在主窗口中,但不影响主窗口的正常使用?
Grouping
The CdsCalcs example has a ClientDataSet component that extracts its data from the familiar Country dataset. The group is obtained, along with the definition of an index, by specifying a grouping level for the index:object ClientDataSet1: TClientDataSet
IndexDefs = <
item
Name = 'ClientDataSet1Index1'
Fields = 'Continent'
GroupingLevel = 1
end>
IndexName = 'ClientDataSet1Index1'When a group is active, you can make it obvious to the user by displaying the grouping structure in the DBGrid, as shown in Figure 13.16. All you have to do is handle the OnGetText event for the grouped field (the Continent field in the example) and show the text only if the record is the first in the group:procedure TForm1.ClientDataSet1ContinentGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
begin
if gbFirst in ClientDataSet1.GetGroupState (1) then
Text := Sender.AsString
else
Text := '';
end;