在stringGrid 中如何在一列中定义一个下拉框,这样在输入性别时就可以选择了。怎么实现?
解决方案 »
- dll delphi7下出错
- 哪位大侠有李维的旧书,小弟愿意高价购买或交换,在意者请留言给我([email protected]),限广州地区
- 如何将文字用二进制表示,并可以还原?
- 如何用EXCEL进行取数,请帮忙,大吓!
- 一个简单的问题关于listview
- 问:该调用什么API获取可执行文件(.Exe,.Dll等)的版本,公司名称,程序名称等信息呢?
- 怎样学进销存方面的编程,请过来人指教?
- 高手帮个忙吧,调试了半天没结果 请看里面的代码
- 关于报表的问题,急急~~~~~~~谢谢各位高手!!
- 联接符 ^ 有什么用啊。
- 好的项目重要,还是好的编程水平重要??
- 請教這樣的問題怎麼用 QrExpr 實現?
输入的时候可以在combobox中选择就可以了撒
ARow: Integer; var CanSelect: Boolean);
var r:TRect;
begin
r:=StringGrid1.CellRect(ACol,ARow);
StringGrid1.DefaultRowHeight:=ComboBox1.Height;
ComboBox1.Left:=StringGrid1.Left + R.Left + 1;
ComboBox1.Top:=StringGrid1.Top + R.Top + 1;
ComboBox1.Width:=R.Right - R.Left;
end;
Panel1的BevelOuter为bvNone,目的使这个Panel1彻底地没有留下痕迹。
再在FROM上放ComboBox1,在它的Items属性上随便放些值。//设置StringGrid的Column要显示的字符。
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Rows[0].Add('for you want');
StringGrid1.Rows[0].Add('測試標准');
StringGrid1.Rows[0].Add('panel');
end;
//在StringGrid的自画事件中,将两个控件摆到StringGrid相应的Cells中
//Panel1.Top:=Rect.Top+StringGrid1.Top+2中的“+2”无非是使控件显示的位置更加准确。
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (gdFocused in State) then
begin
if (StringGrid1.Cells[Acol,0]='測試標准') then
begin
ComboBox1.Left:=Rect.Left+StringGrid1.Left;
ComboBox1.Top:=Rect.Top+StringGrid1.Top+3;
ComboBox1.Width:=Rect.Right-Rect.Left+2;
ComboBox1.Visible:=true;
ComboBox1.SetFocus;
ComboBox1.Text:=StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row];
end
else
ComboBox1.Visible := False;
if (StringGrid1.Cells[Acol,0]='panel') then
begin
Panel1.Left:=Rect.Right + StringGrid1.Left - Panel1.Width;
Panel1.Top:=Rect.Top+StringGrid1.Top+2;
Panel1.Height:=Rect.Bottom-Rect.Top;
Panel1.Visible:=True;
end
else
Panel1.Visible := False;
end;
end;
//将选取到的ComboBox值赋值到StringGrid相应的Cells中。
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row]:=ComboBox1.Items[ComboBox1.ItemIndex];
end;//在SpeedButton1的点击事件中做你想到做的事情。