如何用鼠标选中dbgrid的多行记录???(200分)

  • 主题发起人 主题发起人 czonghui
  • 开始时间 开始时间
DBGrid Options属性选定dgMultiSelect
按住Shift, Ctrl选多条记录
从SelectedRows中获取选中的记录
 
hubdog的宝典里的

TDBGrid的多选特性


// property SelectedRows: TBookmarkList read FBookmarks;

// TBookmarkList = class
// public

{* The Clear method will free all the selected records
within the DBGrid *}
// procedure Clear;

{* The Delete method will delete all the selected rows
from the dataset *}
// procedure Delete;

{* The Find method determines whether a bookmark is

in the selected list. *}
// function Find(const Item: TBookmarkStr;
// var Index: Integer): Boolean;

{* The IndexOf method returns the index of the
bookmark within the Items property. *}
// function IndexOf(const Item: TBookmarkStr): Integer;

{* The Refresh method returns a boolean value to notify
whether any orphans were dropped (deleted) during the
time the record has been selected in the grid. The
refresh method can be used to update the selected list

to minimize the possibility of accessing a deleted
record. *}
// function Refresh: Boolean; True = orphans found

{* The Count property returns the number of currently
selected items in the DBGrid *}
// property Count: Integer read GetCount;

{* The CurrentRowSelected property returns a boolean
value and determines whether the current row is
selected or not. *}
// property CurrentRowSelected: Boolean
// read GetCurrentRowSelected

// write SetCurrentRowSelected;

{* The Items property is a TStringList of
TBookmarkStr *}
// property Items[Index: Integer]: TBookmarkStr
// read GetItem; default;

// end;

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, DBGrids, DB, DBTables;

type
TForm1 = class(TForm)
Table1: TTable;
DBGrid1: TDBGrid;
Count: TButton;
Selected: TButton;

Clear: TButton;
Delete: TButton;
Select: TButton;
GetBookMark: TButton;
Find: TButton;
FreeBookmark: TButton;
DataSource1: TDataSource;
procedure CountClick(Sender: TObject);
procedure SelectedClick(Sender: TObject);
procedure ClearClick(Sender: TObject);
procedure DeleteClick(Sender: TObject);
procedure SelectClick(Sender: TObject);
procedure GetBookMarkClick(Sender: TObject);
procedure FindClick(Sender: TObject);

procedure FreeBookmarkClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Bookmark1: TBookmark;
z: Integer;

implementation

{$R *.DFM}

//Example of the Count property
procedure TForm1.CountClick(Sender: TObject);
begin
if DBgrid1.SelectedRows.Count > 0 then
begin
showmessage(inttostr(DBgrid1.SelectedRows.Count));
end;
end;

//Example of the CurrentRowSelected property

procedure TForm1.SelectedClick(Sender: TObject);
begin
if DBgrid1.SelectedRows.CurrentRowSelected then
showmessage('Selected');
end;

//Example of the Clear Method
procedure TForm1.ClearClick(Sender: TObject);
begin
dbgrid1.SelectedRows.Clear;
end;

//Example of the Delete Method
procedure TForm1.DeleteClick(Sender: TObject);
begin
DBgrid1.SelectedRows.Delete;
end;

{*
This example iterates through the selected rows
of the grid and displays the second field of

the dataset.

The Method DisableControls is used so that the
DBGrid will not update when the dataset is changed.
The last position of the dataset is saved as
a TBookmark.

The IndexOf method is called to check whether or
not the bookmark is still existent.
The decision of using the IndexOf method rather
than the Refresh method should be determined by the
specific application.
*}

procedure TForm1.SelectClick(Sender: TObject);
var

x: word;
TempBookmark: TBookMark;
begin
DBGrid1.Datasource.Dataset.DisableControls;
with DBgrid1.SelectedRows do
if Count > 0 then
begin
TempBookmark:= DBGrid1.Datasource.Dataset.GetBookmark;
for x:= 0 to Count - 1 do
begin
if IndexOf(Items[x]) > -1 then
begin
DBGrid1.Datasource.Dataset.Bookmark:= Items[x];
showmessage(DBGrid1.Datasource.Dataset.Fields[1].AsString);
end;
end;
DBGrid1.Datasource.Dataset.GotoBookmark(TempBookmark);

DBGrid1.Datasource.Dataset.FreeBookmark(TempBookmark);
end;
DBGrid1.Datasource.Dataset.EnableControls;
end;

{*
This example allows you to set a bookmark and
and then search for the bookmarked record within
selected a record(s) within the DBGrid.
*}

//Sets a bookmark
procedure TForm1.GetBookMarkClick(Sender: TObject);
begin
Bookmark1:= DBGrid1.Datasource.Dataset.GetBookmark;
end;

//Frees the bookmark
procedure TForm1.FreeBookmarkClick(Sender: TObject);

begin
if assigned(Bookmark1) then
begin
DBGrid1.Datasource.Dataset.FreeBookmark(Bookmark1);
Bookmark1:= nil;
end;
end;

//Uses the Find method to locate the position of the
//bookmarked record within the selected list in the DBGrid
procedure TForm1.FindClick(Sender: TObject);
begin
if assigned(Bookmark1) then
begin
if DBGrid1.SelectedRows.Find(TBookMarkStr(Bookmark1),z) then
showmessage(inttostr(z));
end;
end;

end.


 
用ip2000 ,非常简单
 
agree with delphi
 
ctrl+click
shift+click
 
不用ctrl键,只使用鼠标,按下左键并拖动选中多行!
 
DBGrid1 --> ListBox1

procedure TForm1.BitBtn1Click(Sender: TObject);
var
i: Integer;
BookmarkList: TBookmarkList;
Bookmark: TBookmark;
begin
Bookmark := Table1.GetBookmark;
ListBox1.Items.Clear;
BookmarkList := DbGrid1.SelectedRows;
for i := 0 to BookmarkList.Count - 1 do
begin
Table1.GotoBookmark(Pointer(BookmarkList));
ListBox1.Items.Add(Table1['taxper_id']); //提取选中列内容
end;
Table1.GotoBookmark(Bookmark);
Table1.FreeBookmark(Bookmark);
end;

procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
BitBtn1.Click
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
//允许DBGrid1多重选择
DBGrid1.Options := DBGrid1.Options + [dgMultiSelect];
end;
 
我也遇到同类问题,可以多个选种,但无法让选种的记录成为蓝色,是否可以将当按左键
时,给DBGRID 发一个ctrl+MOUSE right 的键值呢 ?
 
使用dbgrideh component
 
我也同意Delphi的意见。。。。。
 
请问田勇:那里有dbgrideh component?
新问题:本人编译Rxlib2.75rxctl5.bpk时,总出现internal error,why????

 
TDBGrid.Options[dgMultiSelect] := True;
再以Ctrl + 鼠标 就可以选择多行了
 
只用鼠标选择,不使用键盘。
 
//本人用ip2000调试通过,请各位大虾执教!
//.cpp文件
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Wwdbgrid"
#pragma link "Wwdbigrd"
#pragma link "Wwdbcomb"
#pragma link "wwdbedit"
#pragma link "Wwdotdot"
#pragma link "wwdblook"
#pragma link "Wwdatsrc"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
MouseMoveFlag=0;
MovingFlag=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::wwDBGrid1CalcCellColors(TObject *Sender,
TField *Field, TGridDrawState State, bool Highlight, TFont *AFont,
TBrush *ABrush)
{
if (((TwwDBGrid *)Sender)->IsSelected())
{
ABrush->Color = clLtGray; //记录选中后设置颜色
AFont->Color = clBlack;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::wwDBGrid1MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
if (MouseMoveFlag) //&amp;&amp; wwDBGrid1->MouseCoord(X,Y).X==0)
{
MovingFlag=1;
XXOld=XXTemp;//保存前一次mouseMove事件的坐标
distOld=XXOld.Y-BegRow;
XXMove=wwDBGrid1->MouseCoord(X,Y);
Edit2->Text=IntToStr(XXMove.Y);
temp=XXMove.Y;
if (temp==-1 || temp==0)//去掉mouse在wwDBgrid上下边界处产生错误行号
return;
MovRow=XXMove.Y;
distNew=MovRow-BegRow;//当前MouseMove事件的坐标
XXTemp=XXMove;
//动态选中拖动记录
if (abs(distNew)>abs(distOld))
{
if (distNew>0)
{
for (i=distOld+BegRow;i<distNew+BegRow;i++)
{
wwDBGrid1->SetActiveRow(i);
wwDBGrid1->SelectRecord();
}
}
else
{
for (i=distOld+BegRow;i>distNew+BegRow;i--)
{
wwDBGrid1->SetActiveRow(i-2);
wwDBGrid1->SelectRecord();
}
}
}
else if(abs(distNew)<abs(distOld))
{
if (distOld>=0)
{
for (i=BegRow+distOld;i>BegRow+distNew;i--)
{
wwDBGrid1->SetActiveRow(i-1);
wwDBGrid1->UnselectRecord();
wwDBGrid1->SetActiveRow(i-2);
}
}
else if (distOld<0)
{
for (i=BegRow+distOld-1;i<BegRow+distNew-1;i++)
{
wwDBGrid1->SetActiveRow(i);
wwDBGrid1->UnselectRecord();
wwDBGrid1->SetActiveRow(i+1);
}
}
}
}
Edit4->Text=wwDBGrid1->SelectedList->Count;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::wwDBGrid1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{ //mouse左键单选
if ((Button==mbLeft) &amp;&amp; (!(Shift.Contains(ssCtrl))))// &amp;&amp; wwDBGrid1->MouseCoord(X,Y).X==0)
{
wwDBGrid1->UnselectAll();
MouseMoveFlag=1;
XXBegin=wwDBGrid1->MouseCoord(X,Y);
BegRow=XXBegin.Y;
wwDBGrid1->SelectRecord();
XXTemp=XXBegin;
}
//按下Ctrl可以多选
if ((Button==mbLeft) &amp;&amp; Shift.Contains(ssCtrl))// &amp;&amp; wwDBGrid1->MouseCoord(X,Y).X==0)
{
MovingFlag=0;
XXCtrl=wwDBGrid1->MouseCoord(X,Y);
if (XXCtrl.Y!=-1 &amp;&amp; XXCtrl.Y!=0)
CtrlRow=XXCtrl.Y;
wwDBGrid1->SetActiveRow(CtrlRow-1);
if (wwDBGrid1->IsSelected()) //如记录已经选中,则不选中该记录
wwDBGrid1->UnselectRecord();
else
wwDBGrid1->SelectRecord();
}
//Mouse在选中记录上按下右键,探出相应menu,否则清除选中记录
if (Button==mbRight)// &amp;&amp; wwDBGrid1->MouseCoord(X,Y).X==0)
{
// if ()
MovingFlag=0;
XXRight=wwDBGrid1->MouseCoord(X,Y);
if (XXRight.Y!=-1 &amp;&amp; XXRight.Y!=0)
wwDBGrid1->SetActiveRow(XXRight.Y-1);
if (wwDBGrid1->IsSelected())
PopupMenu1->Popup(ClientToScreen(Point(X,Y)).x,ClientToScreen(Point(X,Y)).y);
else
wwDBGrid1->UnselectAll();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::wwDBGrid1MouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{ //mouse处于拖动选中状态时,鼠标移动过快可能出现漏选记录
//在mouseUp事件中刷新选中记录
MouseMoveFlag=0;
XXTemp=wwDBGrid1->MouseCoord(X,Y);
if (XXBegin.X==0 &amp; XXBegin.Y==0 &amp;&amp; XXTemp.X==0 &amp; XXTemp.Y==0)
return;//左上角按钮按下,程序返回
if ((Button==mbLeft) &amp;&amp; (MovingFlag==1))// &amp;&amp; wwDBGrid1->MouseCoord(X,Y).X==0)
{
temp=XXTemp.Y;

if ((temp!=-1) &amp;&amp; (temp!=0))
{
MovRow=temp;
}
distNew=MovRow-BegRow;
wwDBGrid1->UnselectAll();

if (distNew>0)
{
if (BegRow==0)
BegRow=1; //如果在Title上按下Mouse,将鼠标位置设置为第一行
for (i=BegRow-1;i<MovRow;i++)
{
wwDBGrid1->SetActiveRow(i);
wwDBGrid1->SelectRecord();
}
}
else
{
for (i=BegRow+1;i>MovRow;i--)
{
wwDBGrid1->SetActiveRow(i-2);
wwDBGrid1->SelectRecord();
}
}
}
Edit4->Text=wwDBGrid1->SelectedList->Count;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::wwDBGrid1CellChanged(TObject *Sender)
{
wwDBGrid1->Repaint();//记录内容改变刷新
}
//---------------------------------------------------------------------------

.h file
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "Wwdbgrid.hpp"
#include "Wwdbigrd.hpp"
#include <ADODB.hpp>
#include <Db.hpp>
#include <Grids.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <DBGrids.hpp>
#include "Wwdbcomb.hpp"
#include "wwdbedit.hpp"
#include "Wwdotdot.hpp"
#include <Mask.hpp>
#include "wwdblook.hpp"
#include "Wwdatsrc.hpp"
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TADOTable *ADOTable1;
TwwDBGrid *wwDBGrid1;
TEdit *Edit1;
TEdit *Edit2;
TEdit *Edit3;
TLabel *Label1;
TLabel *Label2;
TLabel *Label3;
TEdit *Edit4;
TPopupMenu *PopupMenu1;
TMenuItem *N1;
TADOTable *ADOTable2;
TwwDataSource *wwDataSource1;
TwwDataSource *wwDataSource2;
TwwDBGrid *wwDBGrid2;
TwwDBLookupCombo *wwDBLookupCombo1;
TSplitter *Splitter1;
void __fastcall wwDBGrid1CalcCellColors(TObject *Sender, TField *Field,
TGridDrawState State, bool Highlight, TFont *AFont,
TBrush *ABrush);
void __fastcall wwDBGrid1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y);
void __fastcall wwDBGrid1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y);
void __fastcall wwDBGrid1MouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y);
void __fastcall wwDBGrid1CellChanged(TObject *Sender);
private: // User declarations
TGridCoord XXMove,XXBegin,XXTemp,XXOld,XXCtrl,XXRight;
short int MouseMoveFlag,MovingFlag;//MouseMoveFlag判断鼠标是否按下后移动,
//MovingFlag判断mouse是否处于拖动多选状态。
int BegRow,MovRow,temp,CtrlRow;//行号
short int distOld,distNew,i;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
 
//本人用ip2000调试通过,请各位大虾执教!
//.cpp文件
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Wwdbgrid"
#pragma link "Wwdbigrd"
#pragma link "Wwdbcomb"
#pragma link "wwdbedit"
#pragma link "Wwdotdot"
#pragma link "wwdblook"
#pragma link "Wwdatsrc"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
MouseMoveFlag=0;
MovingFlag=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::wwDBGrid1CalcCellColors(TObject *Sender,
TField *Field, TGridDrawState State, bool Highlight, TFont *AFont,
TBrush *ABrush)
{
if (((TwwDBGrid *)Sender)->IsSelected())
{
ABrush->Color = clLtGray; //记录选中后设置颜色
AFont->Color = clBlack;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::wwDBGrid1MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
if (MouseMoveFlag) //&amp;&amp; wwDBGrid1->MouseCoord(X,Y).X==0)
{
MovingFlag=1;
XXOld=XXTemp;//保存前一次mouseMove事件的坐标
distOld=XXOld.Y-BegRow;
XXMove=wwDBGrid1->MouseCoord(X,Y);
Edit2->Text=IntToStr(XXMove.Y);
temp=XXMove.Y;
if (temp==-1 || temp==0)//去掉mouse在wwDBgrid上下边界处产生错误行号
return;
MovRow=XXMove.Y;
distNew=MovRow-BegRow;//当前MouseMove事件的坐标
XXTemp=XXMove;
//动态选中拖动记录
if (abs(distNew)>abs(distOld))
{
if (distNew>0)
{
for (i=distOld+BegRow;i<distNew+BegRow;i++)
{
wwDBGrid1->SetActiveRow(i);
wwDBGrid1->SelectRecord();
}
}
else
{
for (i=distOld+BegRow;i>distNew+BegRow;i--)
{
wwDBGrid1->SetActiveRow(i-2);
wwDBGrid1->SelectRecord();
}
}
}
else if(abs(distNew)<abs(distOld))
{
if (distOld>=0)
{
for (i=BegRow+distOld;i>BegRow+distNew;i--)
{
wwDBGrid1->SetActiveRow(i-1);
wwDBGrid1->UnselectRecord();
wwDBGrid1->SetActiveRow(i-2);
}
}
else if (distOld<0)
{
for (i=BegRow+distOld-1;i<BegRow+distNew-1;i++)
{
wwDBGrid1->SetActiveRow(i);
wwDBGrid1->UnselectRecord();
wwDBGrid1->SetActiveRow(i+1);
}
}
}
}
Edit4->Text=wwDBGrid1->SelectedList->Count;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::wwDBGrid1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{ //mouse左键单选
if ((Button==mbLeft) &amp;&amp; (!(Shift.Contains(ssCtrl))))// &amp;&amp; wwDBGrid1->MouseCoord(X,Y).X==0)
{
wwDBGrid1->UnselectAll();
MouseMoveFlag=1;
XXBegin=wwDBGrid1->MouseCoord(X,Y);
BegRow=XXBegin.Y;
wwDBGrid1->SelectRecord();
XXTemp=XXBegin;
}
//按下Ctrl可以多选
if ((Button==mbLeft) &amp;&amp; Shift.Contains(ssCtrl))// &amp;&amp; wwDBGrid1->MouseCoord(X,Y).X==0)
{
MovingFlag=0;
XXCtrl=wwDBGrid1->MouseCoord(X,Y);
if (XXCtrl.Y!=-1 &amp;&amp; XXCtrl.Y!=0)
CtrlRow=XXCtrl.Y;
wwDBGrid1->SetActiveRow(CtrlRow-1);
if (wwDBGrid1->IsSelected()) //如记录已经选中,则不选中该记录
wwDBGrid1->UnselectRecord();
else
wwDBGrid1->SelectRecord();
}
//Mouse在选中记录上按下右键,探出相应menu,否则清除选中记录
if (Button==mbRight)// &amp;&amp; wwDBGrid1->MouseCoord(X,Y).X==0)
{
// if ()
MovingFlag=0;
XXRight=wwDBGrid1->MouseCoord(X,Y);
if (XXRight.Y!=-1 &amp;&amp; XXRight.Y!=0)
wwDBGrid1->SetActiveRow(XXRight.Y-1);
if (wwDBGrid1->IsSelected())
PopupMenu1->Popup(ClientToScreen(Point(X,Y)).x,ClientToScreen(Point(X,Y)).y);
else
wwDBGrid1->UnselectAll();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::wwDBGrid1MouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{ //mouse处于拖动选中状态时,鼠标移动过快可能出现漏选记录
//在mouseUp事件中刷新选中记录
MouseMoveFlag=0;
XXTemp=wwDBGrid1->MouseCoord(X,Y);
if (XXBegin.X==0 &amp; XXBegin.Y==0 &amp;&amp; XXTemp.X==0 &amp; XXTemp.Y==0)
return;//左上角按钮按下,程序返回
if ((Button==mbLeft) &amp;&amp; (MovingFlag==1))// &amp;&amp; wwDBGrid1->MouseCoord(X,Y).X==0)
{
temp=XXTemp.Y;

if ((temp!=-1) &amp;&amp; (temp!=0))
{
MovRow=temp;
}
distNew=MovRow-BegRow;
wwDBGrid1->UnselectAll();

if (distNew>0)
{
if (BegRow==0)
BegRow=1; //如果在Title上按下Mouse,将鼠标位置设置为第一行
for (i=BegRow-1;i<MovRow;i++)
{
wwDBGrid1->SetActiveRow(i);
wwDBGrid1->SelectRecord();
}
}
else
{
for (i=BegRow+1;i>MovRow;i--)
{
wwDBGrid1->SetActiveRow(i-2);
wwDBGrid1->SelectRecord();
}
}
}
Edit4->Text=wwDBGrid1->SelectedList->Count;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::wwDBGrid1CellChanged(TObject *Sender)
{
wwDBGrid1->Repaint();//记录内容改变刷新
}
//---------------------------------------------------------------------------

.h file
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "Wwdbgrid.hpp"
#include "Wwdbigrd.hpp"
#include <ADODB.hpp>
#include <Db.hpp>
#include <Grids.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <DBGrids.hpp>
#include "Wwdbcomb.hpp"
#include "wwdbedit.hpp"
#include "Wwdotdot.hpp"
#include <Mask.hpp>
#include "wwdblook.hpp"
#include "Wwdatsrc.hpp"
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TADOTable *ADOTable1;
TwwDBGrid *wwDBGrid1;
TEdit *Edit1;
TEdit *Edit2;
TEdit *Edit3;
TLabel *Label1;
TLabel *Label2;
TLabel *Label3;
TEdit *Edit4;
TPopupMenu *PopupMenu1;
TMenuItem *N1;
TADOTable *ADOTable2;
TwwDataSource *wwDataSource1;
TwwDataSource *wwDataSource2;
TwwDBGrid *wwDBGrid2;
TwwDBLookupCombo *wwDBLookupCombo1;
TSplitter *Splitter1;
void __fastcall wwDBGrid1CalcCellColors(TObject *Sender, TField *Field,
TGridDrawState State, bool Highlight, TFont *AFont,
TBrush *ABrush);
void __fastcall wwDBGrid1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y);
void __fastcall wwDBGrid1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y);
void __fastcall wwDBGrid1MouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y);
void __fastcall wwDBGrid1CellChanged(TObject *Sender);
private: // User declarations
TGridCoord XXMove,XXBegin,XXTemp,XXOld,XXCtrl,XXRight;
short int MouseMoveFlag,MovingFlag;//MouseMoveFlag判断鼠标是否按下后移动,
//MovingFlag判断mouse是否处于拖动多选状态。
int BegRow,MovRow,temp,CtrlRow;//行号
short int distOld,distNew,i;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
 
多人接受答案了。
 
后退
顶部