国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

DBGrid中用光標(biāo)鍵控制Cell

2019-11-18 18:03:23
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
 

{////////////////////////
//                     //
//     Grids549        //
//                     //
//   14:33 2005-2-17   //
//                     //
}////////////////////////
unit Grids549;

interface

uses
  DBGrids, Classes, Windows;

type
  TDBGrid549 = class(TDBGrid)
  public
    PRoperty InPlaceEditor;
  end ;
 
procedure CursorCtrl(Sender: TObject; var Key: Word; Shift: TShiftState); 

implementation

{ TDBGrid549 }

procedure CursorCtrl(Sender: TObject; var Key: Word;
  Shift: TShiftState);
{
Warn: This procedure may change VK_RIGHT and VK_LEFT to 0

Call this in DBGridKeyDown procedrue
eg:
procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  Grids549.CursorCtrl(Sender, Key, Shift);
end;
}
var
  GridEditorMode: Boolean;
begin
  if Shift <> [] then Exit;
  if (Key <> VK_RIGHT) and (Key <> VK_LEFT) then
    Exit;
  GridEditorMode := TDBGrid(Sender).EditorMode;
  if not GridEditorMode then
    TDBGrid(Sender).EditorMode := True;
 
  if Key = VK_RIGHT then begin
    if GridEditorMode and (TDBGrid549(Sender).InplaceEditor.SelStart <>
      Length(TDBGrid549(Sender).InplaceEditor.Text)) then begin
      Exit;
    end;
    //Last field, move to next record     
    if TDBGrid(Sender).SelectedIndex =
      TDBGrid(Sender).FieldCount - 1 then begin
      TDBGrid(Sender).DataSource.DataSet.Next;
      TDBGrid(Sender).SelectedIndex := 0;
    end
    else
    //Focus on next field
    if TDBGrid(Sender).EditorMode then begin
      TDBGrid(Sender).SelectedIndex := TDBGrid(Sender).SelectedIndex + 1;
    end;
  end
  else
  if Key = VK_LEFT then begin
    if GridEditorMode and(TDBGrid549(Sender).InplaceEditor.SelStart <> 0) then
      Exit;
    //First field, move to prior record
    if TDBGrid(Sender).SelectedIndex = 0 then begin
        TDBGrid(Sender).DataSource.DataSet.Prior;
        TDBGrid(Sender).SelectedIndex := TDBGrid(Sender).FieldCount - 1;
    end
    else
    //Focus on prior field
    if TDBGrid(Sender).EditorMode then begin
      TDBGrid(Sender).SelectedIndex := TDBGrid(Sender).SelectedIndex - 1;
    end;
  end;
  Key := 0;
end;

end.


上一篇:檢查RS232(串口)是否接有設(shè)備

下一篇:一個(gè)很實(shí)用的Ehlib排序函數(shù),適合ADO

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
學(xué)習(xí)交流
熱門圖片

新聞熱點(diǎn)

疑難解答

圖片精選

網(wǎng)友關(guān)注

主站蜘蛛池模板: 雷波县| 涟源市| 临邑县| 依安县| 平定县| 清远市| 平乐县| 庄浪县| 邵东县| 江达县| 高清| 寿光市| 浦江县| 嘉定区| 万载县| 宁国市| 沭阳县| 高雄县| 自治县| 淮阳县| 鄂伦春自治旗| 南昌市| 千阳县| 新密市| 抚宁县| 莲花县| 安庆市| 龙门县| 桃园县| 苗栗县| 曲松县| 平原县| 望都县| 曲麻莱县| 扎赉特旗| 德钦县| 融水| 扬州市| 合山市| 任丘市| 泽州县|