如题
解决方案 »
- 被忽悠了哦.重新找答案,出最后的100分 求助资源方面的问题.
- Windows下文件备份到磁带,是否和访问磁盘一样呢
- 求购服装外贸软件!
- 有没有这样的控件:让StringGrid的单元格有自动换行的功能?
- 救急————〉关于安装程序的制作(斑竹,救我)
- 极菜的问题(望星星们不吝赐教)
- 我用ado连接的主从表,从表的记录不能删除
- 請問高手,哪裡有delphi的XLReport控件下載,不用注冊的那種,謝謝!
- 一个关于做资料的事!?时间的问题!
- 大虾请进------------请教一个字符串的处理--------------
- 关于窗体上的components中的索引值的问题!急的人发疯!
- 请问如何调试COM
我继承TstirngGrid做了一个控件,想让它响应TitleClick,该如何进行
1、StringGrid被点击后,判断是不是第0行。
2、用第三方控件。
3、为什么不用ListView呢?
1,StringGrid的Fixed根本不响应OnClick事件
2,版权,费用,安全,。。
3,用StringGrid的目的是显示不定几列的汇总,并同时具有数据网格的特点
本人觉得楼主是否可以换个角度考虑这个问题。
如果你是想显示不定列的汇总。 可以考虑换个数据集控件。
TClientDataSet。用它可以创建一个虚拟的表。你可以显示
任意你想显示的东东。当然,数据浏览控件还是用DBGrid。 如果需要,可以给你源码。
谢谢,但是DbGrid无法生成汇总行,例如:
商品名 数量
图书 3
铅笔 5
合计 8
标题:字符网格排序
说明:升序、降序;示例点击标题排序
设计:Zswang
日期:2002-04-27
支持:[email protected]
//*)///////Begin Source
function StringGridRowSwap(mStringGrid: TStringGrid;
mFromRow, mToRow: Integer): Boolean;
var
S: string;
begin
Result := False;
if (mToRow = mFromRow) then Exit;
if not Assigned(mStringGrid) then Exit;
if (mFromRow < 0) or (mFromRow >= mStringGrid.RowCount) then Exit;
if (mToRow < 0) or (mToRow >= mStringGrid.RowCount) then Exit;
try
S := mStringGrid.Rows[mFromRow].Text;
mStringGrid.Rows[mFromRow].Text := mStringGrid.Rows[mToRow].Text;
mStringGrid.Rows[mToRow].Text := S;
except
Exit;
end;
Result := True;
end; { StringGridRowSwap }function StringGridRowSort(mStringGrid: TStringGrid;
mColIndex: Integer; mDesc: Boolean = False): Boolean;
var
I, J: Integer;
begin
Result := False;
if not Assigned(mStringGrid) then Exit;
if (mColIndex < 0) or (mColIndex >= mStringGrid.ColCount) then Exit;
for I := mStringGrid.FixedRows to mStringGrid.RowCount - 2 do
for J := I + 1 to mStringGrid.RowCount - 1 do
if mDesc then
if mStringGrid.Cells[mColIndex, I] < mStringGrid.Cells[mColIndex, J] then
StringGridRowSwap(mStringGrid, I, J)
else
else if mStringGrid.Cells[mColIndex, I] > mStringGrid.Cells[mColIndex, J] then
StringGridRowSwap(mStringGrid, I, J);
Result := True;
end; { StringGridRowSort }
///////End Source///////Begin Demo
procedure TForm1.StringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
{$J+}
const
vOldCol: Integer = -1;
{$J-}
var
vCol, vRow: Integer;
begin
if Button = mbRight then Exit;
TStringGrid(Sender).MouseToCell(X, Y, vCol, vRow);
if (vRow < 0) or (vRow >= TStringGrid(Sender).FixedRows) then Exit;
StringGridRowSort(TStringGrid(Sender), vCol, vOldCol = vCol);
if vOldCol = vCol then
vOldCol := - vOldCol
else vOldCol := vCol;
end;
///////End Demo
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Y < StringGrid1.RowHeights[0] then
begin
//在这里可以计算出点击了哪个Title(根据列总长度(用TCustomGrid.ColWidths
//得到)和X)
end;
end;—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
//原文:
// 我自己解决了,可以在MouthDown中写代码,计算鼠标位置 可以散分了吧,实际上你用的和大家说的是一致的,只是使用的事件不同,效果是一样的,不信可以试试。
:)