当前位置:首页
开发技术指南» 文章正文
    引言:

 ·求各位朋友帮帮我     »显示摘要«
    摘要: #include<iostream.h> void main() { int a=1; int b; b=(++a)+(++a); cout<<b<<endl; } 请教各位为什么结果是6???百思不得其解!!! ......
    摘要: 如何在dbgrid中固定选中的列让它不随水平滚动条的滚动而滚动? 请各路大虾指点!!! ......


8分一个delphi的小问题.....

在delphi开发系统中,用dbgrid作为输入画面,   如果我想用dbcombobox   组合框控件   ,即在dbgrid中  
  显示组合框   ,有什么方法可以做到......  
   
  就像以前的vfp   中grid   里可以自由的加listbox,combobox等控件,不知delphi可否

NO.1   作者: quicksand201

DBGrid指定列上显示DBComboBox  
  设置DBGrid1的OnDrawDataCell事件如下:  
  procedure   TForm1.DBGrid1DrawDataCell(Sender:   TObject;   const   Rect:   TRect;   Field:   TField;   State:   TGridDrawState);  
  begin  
      if   (gdFocused   in   State)   then  
      begin  
          if   (Field.FieldName   =   DBComboBox1.DataField   )   then  
          begin  
              DBComboBox1.Left   :=   Rect.Left   +   DBGrid1.Left;  
              DBComboBox1.   :=   Rect.   +   DBGrid1.top;  
              DBComboBox1.Width   :=   Rect.Right   -   Rect.Left;  
              DBComboBox1.Height   :=   Rect.Bottom   -   Rect.;  
              DBComboBox1.Visible   :=   True;  
          end;  
      end;  
  end;  
  2)、DBGrid指定单元格未获得焦点时不显示DBComboBox,设置DBGrid1的OnColExit事件如下:  
  procedure   TForm1.DBGrid1ColExit(Sender:   TObject);  
  begin  
      If   DBGrid1.SelectedField.FieldName   =   DBComboBox1.DataField   then  
          begin  
              DBComboBox1.Visible   :=   false;  
          end;  
  end;  
  3)、当DBGrid指定列获得焦点时DrawDataCell事件只是绘制单元格,并显示DBComboBox,但是DBComboBox并没有获得焦点,数据的输入还是在单元格上进行。在DBGrid1的KeyPress事件中调用SendMessage这个   Windows   API函数将数据输入传输到DBComboBox上,从而达到在DBComboBox上进行数据输入。因此还要设置KeyPress事件如下:  
  procedure   TForm1.DBGrid1KeyPress(Sender:   TObject;   var   Key:   Char);  
  begin  
      if   (key   <   >   chr(9))   then  
      begin  
          if   (DBGrid1.SelectedField.FieldName   =DBComboBox1.DataField)   then  
          begin  
              DBComboBox1.SetFocus;  
              SendMessage(DBComboBox1.Handle,WM_Char,word(Key),0);  
          end;  
      end;  
  end;  
 


    摘要: 哪位能告诉我从哪儿得到wtsapi32.h文件啊 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE