DelphiÖÐΪDBGrid¿Ø¼þÌí¼ÓÉ«²Ê
DelphiÖÐΪDBGrid¿Ø¼þÌí¼ÓÉ«²Ê
2005-08-08 09:13×÷ÕߣºÐ¡µ¶ÇáÎè³ö´¦£ºÌ켫ÍøÔðÈα༣º·½ÖÛ
¡¡¡¡Ìí¼Ó²»Í¬ÑÕÉ«µ½TDBGrid×é¼þÖн«»áÔöÇ¿×é¼þµÄÏÔʾÍâ¹ÛºÍÇø±ðÊý¾Ý¿âÖв»Í¬ÄÚÈݵÄÐлòÁС£
¡¡¡¡TDBGrid×é¼þÊÇÒ»Öַdz£°ôµÄÓÃÀ´ÏÔʾÊý¾ÝÄÚÈݵÄ×é¼þ£¬±¾ÎĵÄÖص㽫ÓÃÀ´½âÊÍ---ÈçºÎÔÚTDBGridÖиıäÌض¨ÐлòÁлòµ¥Ôª¸ñµÄÑÕÉ«¡£
¡¡¡¡×¼±¸½×¶Î£º
¡¡¡¡±¾ÎļÙÉèÄãÒѾ֪µÀÈçºÎ½«Ò»¸öTDBGridÓëÊý¾Ý¿âÏàÁª½Ó£¬×îÈÝÒ׵ķ½·¨ÊÇʹÓÓDatabase Form Wizard”£¬½«TDBGridÓëDBDemo£¨Delphi×Ô´øÊý¾Ý¿âÖеÄemployee.dbÏàÁª½Ó£¬Ñ¡Ôñ³ýExceptÖ®ÍâµÄËùÓÐ×ֶΡ£
¡¡¡¡¸øTDBGridÉÏÑÕÉ«
¡¡¡¡ÎªÁÐÉÏÉ«
¡¡¡¡µÚÒ»ÖÖÊÇ×îÈÝÒ×µÄÒ»ÀàÉÏÉ«£¬×îÖ±½ÓµÄÈÃÄãµÄÓû§¿´µ½£¬ÎªTDBGridÖÐÖ¸¶¨µÄijһÁÐÉÏÉ«¡£
¡¡¡¡ÎÒÃDzÉÓõķ½·¨ÊÇͨ¹ýTDBGridµÄTColumnsÊôÐÔÀ´Íê³É¡£²½ÖèÈçÏ£º
¡¡ ¡¡ÓÃÊó±êÑ¡ÔñFormÉϵÄTDBGrid×é¼þ£¬ÔÚObject InspectorÖÐË«»÷TDBGridµÄColumnsÊôÐÔ´ò¿ªColumns±à¼´°¿Ú¡££¨ÏëÁ˽â¸ü¶àÄÚÈݲéÔÄDelphi°ïÖúÖеēColumns editor: creating persistent columns”Ö÷Ìâ¡££©
¡¡¡¡ÏÂÃæÄãËùÒª×öµÄ¾ÍÊÇÖ¸¶¨ÄãÐèÒª¸Ä±äÑÕÉ«µÄÄÇÒ»Ðлò¼¸Ðеı³¾°ÑÕÉ«£¬Èç¹ûÄãÒª¸Ä±ä×ÖÌåÑÕÉ«£¬¾Í½«FontÊôÐÔ¼¯ÖеÄColorÊôÐÔÐÞ¸Äһϡ£
ͼ1
¡¡¡¡¾ÍÊÇÕâô¼òµ¥£¬Ö»ÒªÇáµã¼¸ÏÂÊó±ê¾Í¿ÉÒÔÁË£¬ÕâÑùÐÞ¸ÄÖ®ºóµÄTDBGrid¾Í²»ÔÙÊÇ´ô°åµÄ°×É«±³¾°ÁË¡£
¡¡¡¡ÎªÐÐÉÏÉ«
¡¡¡¡µÚ1ÖÖÈç¹ûÄãÏëҪΪTDBGridÖÐËùÑ¡µÄijһ¸ñ»òijЩ¸ñÖ¸¶¨ÑÕÉ«£¬¶øÇÒÄã²»ÏëʹÓÃdgRowSelectÑ¡ÏÒòΪÄãÏëÈÃTDBGrid¿ÉÒÔÖ±½ÓÔÚTDBGridµ¥Ôª¸ñÖбà¼Êý¾Ý£¬ÄãÓ¦¸ÃʹÓÃTDBGridµÄOnDrawColumnCellʼþ¡£
¡¡¡¡ÏÂÃæÎÒÃÇÓõ½µÄ¼¼ÇÉ¿ÉÒÔ¶¯Ì¬¸Ä±äTDBGridÖеĵ¥Ôª¸ñÎı¾µÄÑÕÉ«¡£
¡¡¡¡´úÂëÈçÏ£º
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
¡¡if Table1.FieldByName(’Salary’).AsCurrency>36000 then
¡¡¡¡//Ö¸¶¨ËùÐè¸Ä±äÑÕÉ«ÐеÄÌõ¼þ±í´ïʽ
¡¡¡¡DBGrid1.Canvas.Font.Color:=clMaroon;
¡¡¡¡//Ö¸¶¨ÑÕɫΪclMaroon
¡¡¡¡DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
¡¡¡¡ÉÏÊö´úÂëÖ´ÐеŦÄÜÊÇ£º°Ñнˮ³¬¹ý3Íò6ǧԪµÄÔ±¹¤£¨employee£©¼Ç¼×ÖÌåÑÕÉ«ÓÃÀõÉ«£¨Maroon£©±ê³öÀ´¡£
ͼ2
¡¡¡¡µÚ2ÖÖ ÈçºÎ¶¯Ì¬¸Ä±äTDBGridÖÐÐеÄÑÕÉ«£¬´ú
Ïà¹ØÎĵµ£º
delphiÖеÄDLLÖеÄÉùÃ÷ÔÂëÈçÏ£º
ÕâÀïÉùÃ÷ÁËÊä³öÐÔ²ÎÊý·Ö±ðΪÊý×ÖÓë×Ö·ûÀàÐÍ
library dll1;
uses
SysUtils,
Classes;
{$R *.res}
Function mymax(x, y: Integer; out jj: Integer; out abc: PChar): Integer; stdcall;
begin
jj := x * y;
abc := PChar(StrPas(abc) + 'ÕâÊÇ´«³öµÄ' ......
¶¨Ò壺
CbName: TComboBox;
width: Integer; //ʵ¼ÊËùÐèµÄ¿í¶È
ÔÚÖ´ÐдúÂëÖа´ÈçÏ·½·¨Ð´£º
width := CbName.Canvas.TextWidth(CbName.Items[I]); //¿ÉÓô˷½·¨Í¨¹ý±éÀú»ñµÃijѡÏîµÄ×î´ó¿í¶È£¬Ò²¿ÉÒÔ°´×Ô¼ºµÄÐ ......
Delphi
DelphiÕâÊÇÒ»¸öwindows×ÀÃæ±à³ÌÈí¼þ£¬ÏÖÔÚ°æ±¾Óкܶ࣬Ö÷ÒªÓõĻ¹ÊÇDelphi7£¬7ÒÔÉϵİ汾¶¼ÐèҪװ.net
¾²Ì¬µ÷ÓúͶ¯Ì¬µ÷Ó㬾²Ì¬µ÷ÓþÍÊÇÖ±½ÓÍù´°ÌåÉÏÍпؼþ£¬¶ø¶¯Ì¬µ÷ÓþÍÊDZàд´úÂëµ÷ÓÿؼþµÄÀàʵÏÖһЩ¹¦ÄÜ¡£
ͨ³£Çé¿ö϶¼ÊÇÕâÁ½ÖÖ·½Ê½Ïà½áºÏµÄʹÓã¬Ëæ×ÅDelphiµÄÉîÈ룬¾Í»á·¢ÏÖÍпؼþ²»ÊÇÍòÄܵģ¬ºÜ¶àʱºò¶¼ ......
VCLÖеÄShapeÊǸöºÜ²»´íµÄ¿Ø¼þ£¬¿ÉÒÔÑ¡Ôñ¼¸ÖÖͼÐΣ¬ÒÔÂú×ãÎÒÃǵÄÐèÇ󣬵«ÓÐʱºò¾ÍÊǾõµÃËüµÄ¿ÉѡͼÐÎÉÙÁËÒ»µã£¬±ÈÈçÎÒÃÇÏëÒªÒ»¸öÈý½ÇÐΣ¬ËüȴûÓС£ÓÚÊǾÍÏëµ½À´À©Õ¹Ò»ÏÂÕâ¸ö¿Ø¼þ£¬ÃûΪShapeEx¡£ÆäʵÀ©Õ¹µÄ¹¦Äܲ»¶à£¬Ö»ÊÇÔö¼ÓÁËһЩͼÐΡ£¶øÀàÒ²²¢²»ÊǼ̳Ð×ÔTShape£¬¶øÊǼ̳Ð×ÔTGraphicControl£¬ÕâÑù¿ÉÒÔÈÃÎÒÃdz¹µ×¿´¿´Í¼ÐÎ ......