今天面试出了这么一个题目考我。
1、设置combobox下拉框的宽度和高度(需要调用API)
2、在combobox下拉框中画上类似excel的表格,表格形式如下:
ID 学校 专业
01 北大 计算机应用
02 清华 数学
03 交大 英语哪位大虾知道,出手帮忙一下啊,兄弟我不胜感激,在线等
1、设置combobox下拉框的宽度和高度(需要调用API)
2、在combobox下拉框中画上类似excel的表格,表格形式如下:
ID 学校 专业
01 北大 计算机应用
02 清华 数学
03 交大 英语哪位大虾知道,出手帮忙一下啊,兄弟我不胜感激,在线等
解决方案 »
- 如何将实数小数部分取出并将其转化成整数
- TreeView1的onchange事件如何中断
- 写个小软件 将<input type="checkbox" name="checkbox2" value="checkbox">等控件转换成.NET服务器端的控件;页面格式不能改变;请问这个
- 谁知道delphi6的下载地址?在线等待,立即给分!
- dbf库时间比较用什么符号?请看一下这句SQL语句是否有错!
- 关于DateTimePicker控件的使用...
- Delphi开发的系统服务程序中如何使用数据库敏感控件?
- 原来这里一个高手都没有?有的话进来看看~
- 我想在Delphi程序里修改.DFM文件要怎么做呢?
- ?? 求解,如何让一个圆形图片围绕自己的圆心旋转 ??
- 怎样判断ADOQuery数据集中的记录数是否为空,也就是判断数据集中是否有数据?
- 哪位有数据导出到excel例子,贴出来看看!!
ComBox.Width:=100;ComBox.Items.add('ID'+#9+'学校'+#9+'专业')
ListBox.Style := lbOwnerDrawFixed;
ListBox.ItemHeight := 50;
或
ListBox.Perform(LB_SETITEMHEIGHT, 0, 50);
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
tTest=record
id :string[2];
xx : string[4];
zy : string[4];
end;
TForm1 = class(TForm)
ComboBox1: TComboBox;
procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
arrayTest : array[0..2] of tTest;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
with (Control as TComboBox).Canvas do
begin
TextOut(rect.Left ,rect.Top,arrayTest[Index].id);
TextOut(rect.Left+30,rect.Top,arrayTest[Index].xx);
TextOut(rect.Left+70,rect.Top,arrayTest[Index].zy);
Pen.Color := clBlack;
MoveTo(rect.Left,rect.Top);
LineTo(rect.Right,rect.Top); MoveTo(rect.Left,rect.Bottom);
LineTo(rect.Right,rect.Bottom); MoveTo(Rect.Left + 26,Rect.Top);
LineTo(rect.Left+26,rect.Bottom); MoveTo(Rect.Left + 65,Rect.Top);
LineTo(rect.Left+65,rect.Bottom);
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.Items.Clear;
arrayTest[0].id := '01';
arraytest[0].xx := '北大';
arrayTest[0].zy := 'plmm';
ComboBox1.Items.Add('01'); arrayTest[1].id := '02';
arraytest[1].xx := '北大';
arrayTest[1].zy := 'make';
ComboBox1.Items.Add('02'); arrayTest[2].id := '03';
arraytest[2].xx := '烂校';
arrayTest[2].zy := '**';
ComboBox1.Items.Add('03'); ComboBox1.ItemIndex := 0;
end;end.
第一个问题是设置item的宽度和高度,能让下拉框有上/下,左/右滚动条
SetWindowPos(ComboBox1.Handle, 0, 0, 0,
200,//这里可以设置宽度
600,//高度
SWP_NOMOVE or SWP_NOZORDER or SWP_NOACTIVATE or SWP_NOREDRAW or
SWP_HIDEWINDOW);至于滚动条
垂直的,当你的列表内容大于总数的时候,就自动出现了
水平的,在基本的combobox上,不知道怎么加如果像完全实现你的功能,从TCombobox类继承,写一个新组件,你可以参考一下VCL的源码.