亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? dbgrid.htm

?? 對(duì)于學(xué)習(xí)很有幫助
?? HTM
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

<HTML>
<HEAD>
	<TITLE>UDDF - DBGRID</TITLE>
	<META NAME="Description" CONTENT="DBGrid section of the Delphi Developers FAQ" >
	<META NAME="KeyWords" CONTENT="" >

</HEAD>

<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#ffffff">

<CENTER>
<IMG SRC="../images/uddf.jpg"> </CENTER>
<H1><A NAME="dbgrid0">Using the Multi Select option of a DBGRID</A></H1>
<I><P>mike@sentex.net (Mike Tancsa)</P>
</I><P>There is an example in the Delphi TIs... Have a look at</P>
<P><A HREF="http://loki.borland.com/winbin/bds.exe?getdoc+2976+delphi">http://loki.borland.com/winbin/bds.exe?getdoc+2976+Delphi</A> </P>
<P><HR></P>
<PRE>{*
   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 &lt;&gt; 0 then
  begin
    TempBookmark:= DBGrid1.Datasource.Dataset.GetBookmark;
    for x:= 0 to Count - 1 do
    begin
      if IndexOf(Items[x]) &gt; -1 then
      begin
        DBGrid1.Datasource.Dataset.Bookmark:= Items[x];
        showmessage(DBGrid1.Datasource.Dataset.Fields[1].AsString);
      end;
    end;
  end;
  DBGrid1.Datasource.Dataset.GotoBookmark(TempBookmark);
  DBGrid1.Datasource.Dataset.FreeBookmark(TempBookmark);
  DBGrid1.Datasource.Dataset.EnableControls;
end;</PRE>


<H1><A NAME="dbgrid1">Dropdownlist in a DBGrid, HOW ?</A></H1>

<I><P>From: Susan &lt;terminal@meinc.com&gt;</P>
</I><P>Q: How do I put components into a TDBGrid?</P>
<P>A: I saw this on compuserve and it is great!</P>
<H2>HOW TO PUT COMPONENTS INTO A GRID</H2>
<P>This article and the accompanying code shows how to put just about any component into a cell on a grid. 
By component I mean anything from a simple combobox to a more complicated dialog box. 
The techniques described below to anything that is termed a visual component. If you can put it into a form you can probably put it into a grid.</P>
<P>There are no new ideas here, in fact, the basic technique simply mimics what the DBGrid does internally. 
The idea is to float a control over the grid. Inside DBGrid is a TDBEdit that moves around the grid. It's that TDBEdit that you key you data into. 
The rest of the unfocused cells are really just pictures. What you will learn here, is how to float any type of visual control/component around the grid.</P>
<H3>COMPONENT #1 - TDBLOOKUPCOMBO</H3>
<P>You need a form with a DBGrid in it. So start an new project and drop a DBGrid into the main form.</P>
<P>Next drop in a TTable and set it's Alias to DBDEMOS, TableName to GRIDDATA.DB and set the Active property to True. 
Drop in a DataSource and set it's DataSet property to point to Table1. Go back to the grid and point it's DataSource property to DataSource1. 
The data from GRIDDATA.DB should appear in your grid..</P>
<P>The first control we are going to put into the grid is a TDBLookupCombo so we need a second table for the lookup. 
Drop a second TTable into the form. Set it's Alias also to DBDEMOS, TableName to CUSTOMER.DB and Active to True. 
Drop in a second data source and set its DataSet to Table2.</P>
<P>Now go get a TDBLookupCombo from the Data Controls pallet and drop it any where on the form, it doesn't matter where since it will 
usually be invisible or floating over the grid. Set the LookuoCombo's properties as follows.</P>
<P><HR></P>
<PRE>        DataSource      DataSource1
        DataField       CustNo
        LookupSource    DataSource2
        LookupField     CustNo
        LookupDisplay   CustNo  {you can change it to Company later but keep it custno for now)</PRE>
<P><HR></P>
<P>So far it's been nothing but boring point and click. Now let's do some coding.</P>
<P>The first thing you need to do is make sure that DBLookupCombo you put into the form is invisible when you run the app. 
So select Form1 into Object Inspector goto the Events tab and double click on the onCreate event. You should now have the shell for the 
onCreate event displayed on your screen.</P>
<P><HR></P>
<PRE>procedure TForm1.FormCreate(Sender: TObject);
begin

end;</PRE>
<P><HR></P>
<P>Set the LookupCombo's visible property to False as follows.</P>
<P><HR></P>
<PRE>procedure TForm1.FormCreate(Sender: TObject);
begin
  DBLookupCombo1.Visible := False;
end;</PRE>
<P><HR></P>
<P>Those of you who are paying attention are probably asking why I didn't just set this in the Object Inspector for the component. 
Actually, you could have. Personally, I like to initialize properties that change at run time in the code. I set static properties that don't change 
as the program runs in the object inspector. I think it makes the code easier to read. </P>
<P>Now we to be able to move this control around the grid. Specifically we want it to automatically appear as you either cursor or 
click into the column labeled DBLookupCombo. This involves defining two events for the grid, OnDrawDataCell and OnColExit. 
First lets do OnDrawDataCell. Double click on the grid's OnDrawDataCell event in the Object Inspector and fill in the code as follows. </P>
<P><HR></P>
<PRE>procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
  Field: TField; State: TGridDrawState);
begin
  if (gdFocused in State) then
  begin
     if (Field.FieldName = DBLookupCombo1.DataField) then
     begin
       DBLookupCombo1.Left := Rect.Left + DBGrid1.Left;
       DBLookupCombo1.Top := Rect.Top + DBGrid1.top;
       DBLookupCombo1.Width := Rect.Right - Rect.Left;
      { DBLookupCombo1.Height := Rect.Bottom - Rect.Top; }
       DBLookupCombo1.Visible := True;
     end;
  end;
end;</PRE>
<P><HR></P>
<P>The reasons for the excessive use begin/end will become clear later in the demo. 
The code is saying that if the State parameter is gdFocused then this particular cell is 
the one highlighted in the grid. Further if it's the highlighted cell and the cell 
has the same field name as the lookup combo's datafield then we need to move the LookupCombo over 
that cell and make it visible. Notice that the position is determined relative to the form 
not to just the grid. So, for example, the left side of LookupCombo needs to be the offset of the 
grid ( DBGrid1.Left) into the form plus the offset of the cell into the grid (Rect.Left).</P>
<P>Also notice that the Height of the LookupCombo has been commented out above.
 The reason is that the LookupCombo has a minimum height. 
You just can't make it any smaller. 
That minimum height is larger than the height of the cell. 
If you un-commented the height line above. 
Your code would change it and then Delphi would immediately change it right back. 
It causes an annoying screen flash so don't fight it. 
Let the LookupCombo be a little larger than the cell. It looks a little funny but it works.</P>
<P>Now just for fun run the program. 
Correct all you missing semi-colons etc.
 Once its running try moving the cursor around the grid. 
Pretty cool, hu? Not! We're only part of the way there. 
We need to hide the LookupCombo when we leave the column. 
So define the grid's onColExit. It should look like this;</P>
<P><HR></P>
<PRE>procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
  If DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField then
    DBLookupCombo1.Visible := false;
end;</PRE>
<P><HR></P>
<P>This uses the TDBGrids SelectedField property to match up the FieldName 
associated with the cell with that of the LookupCombo. The code says, 
&quot;If the cell you are leaving was in the DBLookupCombo column then make it invisible&quot;.</P>
<P>Now run it again. Was that worth the effort or what?</P>
<P>Now things look right but we're still missing one thing. 
Try typing a new customer number into one of the LookupCombo. 
The problem is that the keystrokes are going to the grid, not to the LookupCombo. 
To fix this we need to define a onKeyPress event for the grid. It goes like this;</P>
<P><HR></P>
<PRE>procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
  if (key &lt;&gt; chr(9)) then
  begin
    if (DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField) then
    begin

      DBLookupCombo1.SetFocus;
      SendMessage(DBLookupCombo1.Handle, WM_Char, word(Key), 0);
    end;
  end;
end;</PRE>
<P><HR></P>
<P>This code is saying that if the key pressed is not a tab key (Chr(9)) and the current field in the grid is the 
LookupCombo then set the focus to the LookupCombo and then pass the 
keystroke over to the LookupCombo. OK so I had to use a WIN API function. 
You don't really need to know how it works just that it works.</P>
<P>But let me explain a bit anyway. 
To make Window's SendMessage function work you must give it the handle of the component you want to send the message to. 
Use the component's Handle property. 
Next it wants to know what the message is. 
In this case it's Window's message WM_CHAR which says I'm sending the LookupCombo a character. 
Finally, you need to tell it which character, so word(Key). That's a typecast to type word of the events Key parameter. 
Clear as mud, right? All you really need to know is to replace the DBLookupCombo1 in the call to the 
name of the component your putting into the grid. If you want more info on SendMessage do a search in Delphi's on-line help.</P>
<P>Now run it again and try typing. It works! Play with it a bit and see how the tab key gets you out of &quot;edit mode&quot; back into 
&quot;move the cell cursor around mode&quot;.</P>
<P>Now go back to the Object Inspector for the DBLookupCombo component and change the LookupDIsplay property to Company. Run it. Imagine the possibilities.</P>
<H3>COMPONENT #2 - TDBCOMBO</H3>
<P>I'm not going to discuss installing the second component, a DBCombo, 
because I don't really have anything new to say. It's really the same as #1. Here's the incrementally developed code for your review.</P>
<P><HR></P>
<PRE>procedure TForm1.FormCreate(Sender: TObject);
begin
  DBLookupCombo1.Visible := False;
  DBComboBox1.Visible := False;
end;

procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
  Field: TField; State: TGridDrawState);
begin
  if (gdFocused in State) then
  begin
     if (Field.FieldName = DBLookupCombo1.DataField) then

     begin
       DBLookupCombo1.Left := Rect.Left + DBGrid1.Left;
       DBLookupCombo1.Top := Rect.Top + DBGrid1.top;
       DBLookupCombo1.Width := Rect.Right - Rect.Left;
       DBLookupCombo1.Visible := True;
     end
     else if (Field.FieldName = DBComboBox1.DataField) then
     begin
       DBComboBox1.Left := Rect.Left + DBGrid1.Left;
       DBComboBox1.Top := Rect.Top + DBGrid1.top;
       DBComboBox1.Width := Rect.Right - Rect.Left;
       DBComboBox1.Visible := True;
     end
  end;
end;

procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
  If DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField then
    DBLookupCombo1.Visible := false
  else If DBGrid1.SelectedField.FieldName = DBComboBox1.DataField then
    DBComboBox1.Visible := false;
end;

procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
  if (key &lt;&gt; chr(9)) then
  begin
    if (DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField) then
    begin
      DBLookupCombo1.SetFocus;
      SendMessage(DBLookupCombo1.Handle, WM_Char, word(Key), 0);
    end
    else if (DBGrid1.SelectedField.FieldName = DBComboBox1.DataField)
then
    begin
      DBComboBox1.SetFocus;
      SendMessage(DBComboBox1.Handle, WM_Char, word(Key), 0);
    end;
  end;
end;</PRE>
<P><HR></P>
<H3>COMPONENT #3 - TDBCHECKBOX</H3>
<P>The DBCheckBox gets even more interesting. 
In this case it seems appropriate to leave something in the non-focused checkbox cells to indicate that there's a check box there. 
You can either draw the &quot;stay behind&quot; image of the checkbox or you can blast in a picture of the checkbox. 
I chose to do the latter. I created two BMP files one that's a picture of the box checked (TRUE.BMP) and one that's a picture of the box unchecked (FALSE.BMP). 
Put two TImage components on the form called ImageTrue and ImageFalse and attach the BMP files to there respective Picture properties. 
Oh yes you also need to put a DBCheckbox component on the form. 
Wire it to the CheckBox field in DataSource1 and set the Color property to clWindow. First edit the onCreate so it reads as follows;</P>
<P><HR></P>
<PRE>procedure TForm1.FormCreate(Sender: TObject);
begin
  DBLookupCombo1.Visible := False;
  DBCheckBox1.Visible := False;
  DBComboBox1.Visible := False;
  ImageTrue.Visible := False;
  ImageFalse.Visible := False;
end;</PRE>
<P><HR></P>
<P>Now we need to modify the onDrawDataCell to do something with cells that do not have the focus. Here comes the code.</P>
<P><HR></P>
<PRE>procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
  Field: TField; State: TGridDrawState);
begin
  if (gdFocused in State) then
  begin
     if (Field.FieldName = DBLookupCombo1.DataField) then
     begin
        ...SEE ABOVE
     end
     else if (Field.FieldName = DBCheckBox1.DataField) then
     begin
       DBCheckBox1.Left := Rect.Left + DBGrid1.Left + 1;
       DBCheckBox1.Top := Rect.Top + DBGrid1.top + 1;
       DBCheckBox1.Width := Rect.Right - Rect.Left{ - 1};
       DBCheckBox1.Height := Rect.Bottom - Rect.Top{ - 1};

       DBCheckBox1.Visible := True;
     end
     else if (Field.FieldName = DBComboBox1.DataField) then
     begin
        ...SEE ABOVE
     end
  end
  else {in this else area draw any stay behind bit maps}
  begin

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美日韩三区| 久久久久亚洲蜜桃| 国产裸体歌舞团一区二区| 一个色在线综合| 国产视频视频一区| 91精品欧美一区二区三区综合在| av成人老司机| 精品亚洲成a人| 无码av免费一区二区三区试看| 国产午夜一区二区三区| 制服丝袜一区二区三区| 在线一区二区三区做爰视频网站| 国产一区二区精品在线观看| 日日摸夜夜添夜夜添亚洲女人| 亚洲欧洲无码一区二区三区| 久久久久久免费网| 91精品国产91久久久久久一区二区| 欧美日韩视频第一区| 精品国产免费人成在线观看| 色呦呦网站一区| 成人午夜大片免费观看| 欧美aaa在线| 视频一区免费在线观看| 一区二区免费看| 亚洲免费看黄网站| 中文字幕中文在线不卡住| 久久久噜噜噜久久中文字幕色伊伊 | 美腿丝袜在线亚洲一区| 亚洲大片免费看| 亚洲一区二区三区小说| 一区二区三区免费在线观看| 综合分类小说区另类春色亚洲小说欧美| 精品免费日韩av| 精品国产电影一区二区| 精品少妇一区二区三区日产乱码| 337p亚洲精品色噜噜噜| 欧美一区二区黄| 日韩亚洲电影在线| 欧美r级在线观看| 久久综合资源网| 久久综合色综合88| 欧美精品一区二区三区在线| 精品三级av在线| 久久久久国产成人精品亚洲午夜| 久久久精品一品道一区| 欧美国产一区视频在线观看| 欧美国产日本视频| 国产精品乱码久久久久久 | 日韩精品电影在线观看| 日韩和欧美一区二区三区| 免费的成人av| 国产精品资源在线观看| 成人免费的视频| 色综合久久六月婷婷中文字幕| 欧洲在线/亚洲| 欧美一级午夜免费电影| 精品国产乱码久久久久久浪潮| 久久亚洲春色中文字幕久久久| 国产午夜精品美女毛片视频| 国产精品久久777777| 亚洲最新视频在线播放| 国产精品免费aⅴ片在线观看| 亚洲欧美激情一区二区| 亚洲成人动漫一区| 精品写真视频在线观看| 成a人片亚洲日本久久| 欧美亚洲免费在线一区| 日韩欧美国产三级电影视频| 日本一区二区三区免费乱视频 | 亚洲一区二区三区小说| 毛片一区二区三区| 白白色 亚洲乱淫| 欧美日韩色综合| 久久久久一区二区三区四区| 亚洲精品国产a| 日韩成人一区二区| 成人永久aaa| 欧美放荡的少妇| 国产精品视频在线看| 亚洲动漫第一页| 国产成人亚洲精品青草天美| 色吊一区二区三区| 精品久久免费看| 亚洲三级久久久| 国内精品在线播放| 欧美在线高清视频| 欧美精品久久99久久在免费线 | 日韩一级黄色片| 国产精品欧美久久久久一区二区| 亚洲国产日韩a在线播放性色| 国产激情视频一区二区三区欧美| 在线精品视频一区二区| www国产成人| 亚洲1区2区3区4区| 成人性生交大片免费看中文网站| 91 com成人网| 亚洲激情网站免费观看| 国产精品亚洲午夜一区二区三区| 欧美日韩一级黄| 亚洲视频在线一区| 国产精品一级黄| 91精品在线观看入口| 亚洲欧美日韩一区二区三区在线观看| 久久99精品久久久久| 欧美色成人综合| 亚洲欧洲精品天堂一级| 国产一区二区三区高清播放| 91精品在线一区二区| 亚洲精品国产精华液| 成人性视频网站| 久久人人爽人人爽| 成人免费看片app下载| 国产一区二区在线观看免费| 欧美在线免费播放| 成人免费一区二区三区在线观看| 国内精品国产三级国产a久久 | 欧美精品一区二区蜜臀亚洲| 亚洲成a人片在线观看中文| 99精品热视频| 国产精品久久久久一区二区三区 | 日本高清不卡在线观看| 中国av一区二区三区| 国产精品一区二区果冻传媒| 精品福利一二区| 极品少妇xxxx精品少妇| 欧美电影精品一区二区| 美日韩一级片在线观看| 欧美一区二区成人6969| 奇米精品一区二区三区在线观看 | 亚洲欧美电影院| 99精品在线观看视频| 国产精品国产自产拍在线| 成人精品一区二区三区四区| 中文字幕乱码日本亚洲一区二区| 国产成人精品一区二| 国产欧美精品国产国产专区| 国产成人精品一区二区三区四区 | 91年精品国产| 亚洲视频一区在线观看| 91在线精品秘密一区二区| 成人欧美一区二区三区黑人麻豆| av一二三不卡影片| 亚洲男人的天堂一区二区| 色天使久久综合网天天| 亚洲一级在线观看| 欧美疯狂做受xxxx富婆| 秋霞国产午夜精品免费视频| 精品福利一二区| 国产成人精品aa毛片| 国产精品久久久久久久午夜片 | 成人一区二区三区| 日韩美女视频一区二区| 在线免费观看日韩欧美| 亚洲成av人片一区二区| 欧美一级免费大片| 国产一级精品在线| 中文字幕一区二区三中文字幕| 色94色欧美sute亚洲线路一久| 亚洲一级二级三级| 精品久久人人做人人爰| av在线播放一区二区三区| 亚洲国产另类av| 精品国产青草久久久久福利| 成人深夜在线观看| 亚洲一区二区四区蜜桃| 精品国产网站在线观看| 91一区二区在线观看| 午夜a成v人精品| 国产欧美日韩另类一区| 欧美午夜不卡视频| 久久国产人妖系列| 成人欧美一区二区三区1314| 日韩av午夜在线观看| 日本精品一区二区三区四区的功能| 亚洲综合精品久久| 日韩欧美在线影院| 成人一区二区三区在线观看 | 国产精品国产三级国产a| 在线观看视频欧美| 久久97超碰色| 亚洲欧美另类图片小说| 精品久久久久久久人人人人传媒| 99精品一区二区| 免费国产亚洲视频| 亚洲女人的天堂| 日韩精品一区二区三区中文精品| bt7086福利一区国产| 奇米777欧美一区二区| 成人免费在线视频观看| 精品日韩在线一区| 欧美色精品天天在线观看视频| 国产尤物一区二区| 午夜伦欧美伦电影理论片| 国产精品久久久久国产精品日日| 91精品国产综合久久香蕉的特点| 91在线视频播放| 国产东北露脸精品视频| 欧美aaaaaa午夜精品| 亚洲精品成人精品456| 国产视频在线观看一区二区三区|