这个怎么做成车载音响电源接线图解?怎么接线?需要单独的电源之类的吗??

Web上功能强大的DbGrid表格HTC组件[只需在Table中指定样式就可以完成多种功能可扩展]
字体:[ ] 类型:转载 时间:
Web上功能强大的DbGrid表格HTC组件[只需在Table中指定样式就可以完成多种功能可扩展]
代码如下: &style& INPUT { DefineINPUTOnClick:expression(this.onclick=function(){if(this.type=="button"){this.style.color=chooseColor();}}); } &/style& &script& var iGridRowCount=0; var iGridColCount=0; function createGrid() { DivID.innerHTML=""; if(iGridRowCount==0){iGridRowCount=5;} if(iGridColCount==0){iGridColCount=5;} var vTable=document.createElement("table"); vTable.style.behavior="url(Grid.htc)"; if(defineGridBgColorID.style.color) {vTable.defineGridBgColor=defineGridBgColorID.style.} if(defineFirstRowBgColorID.style.color) {vTable.defineFirstRowBgColor=defineFirstRowBgColorID.style.} if(defineFirstColBgColorID.style.color) {vTable.defineFirstColBgColor=defineFirstColBgColorID.style.} if(defineCurRowBgColorID.style.color) {vTable.defineCurRowBgColor=defineCurRowBgColorID.style.} if(defineCurColBgColorID.style.color) {vTable.defineCurColBgColor=defineCurColBgColorID.style.} if(defineCurEditBgColorID.style.color) {vTable.defineCurEditBgColor=defineCurEditBgColorID.style.} for(mIndex=0;mIndex&iGridRowCmIndex++) { var vTr=vTable.insertRow(mIndex); for(nIndex=0;nIndex&iGridColCnIndex++) { vTd=vTr.insertCell(nIndex); vTd.innerText="行"+mIndex+"列"+nI } } DivID.appendChild(vTable); } function chooseColor() { var strColor=DlgHelper.ChooseColorDlg(); strColor=strColor.toString(16); if(strColor.length&6) { var sTempString="000000".substring(0,6-strColor.length); strColor=sTempString.concat(strColor); } return strC } &/script& &div id="DivID"&&/div& &object id="DlgHelper" classid="clsid:b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"&&/object& &fieldset& &button onclick="window.confirm('已实现功能')"&Grid参数区&/button&&br& &input type=button value="表格背景" id="defineGridBgColorID"&&br& &input type=button value="头行背景" id="defineFirstRowBgColorID"&&br& &input type=button value="头列背景" id="defineFirstColBgColorID"&&br& &input type=button value="当前选择行背景" id="defineCurRowBgColorID"&&br& &input type=button value="当前选择列背景" id="defineCurColBgColorID"&&br& &input type=button value="当前选择编辑单元格背景" id="defineCurEditBgColorID"&&br& &button onclick="window.confirm('未实现功能')"&保留功能区&/button&&br& &input type=text value="" id="defineGridRowCount"&&button onclick="iGridRowCount=defineGridRowCount."&行数&/button&&br& &input type=text value="" id="defineGridColCount"&&button onclick="iGridColCount=defineGridColCount."&列数&/button&&br& &input type=radio&是&input type=radio&否启动行调整&br& &input type=radio&是&input type=radio&否启动列调整&br& &input type=radio&是&input type=radio&否启动单元格编辑&br& &button onclick="createGrid()"&创建表格&/button&&br& &/fieldset&
代码如下: &public:property name="defineGridBgColor"& &public:property name="defineFirstRowBgColor"& &public:property name="defineFirstColBgColor"& &public:property name="defineCurRowBgColor"& &public:property name="defineCurColBgColor"& &public:property name="defineCurEditBgColor"& &public:attach event=oncontentready onevent="initGrid()"& &script& //常量[可以设置为属性] var rgbGridBgColor="#E1E4EC";//表格背景 var rgbFirstRowBgColor="#6699CC";//头行背景 var rgbFirstColBgColor="#6699CC";//头列背景 var rgbCurRowBgColor="#BBCCDD";//当前选择行背景 var rgbCurColBgColor="#BBCCDD";//当前选择列背景 var rgbCurEditBgColor="#FFFFFF";//当前选择编辑单元格背景 //表格列数 var iColCount=0; //表格行数 var iRowCount=0; //当前选择行 var iCurRowIndex=0; //当前选择列 var iCurColIndex=0; var bIsDragRow=//行是否拖动状态 var bIsDragCol=//列是否拖动状态 var iDragHistoryRowIndex=0;//拖动前原始行位置索引 var iDragCurrentRowIndex=0;//拖动后目的行位置索引 var iDragHistoryColIndex=0;//拖动前原始列位置索引 var iDragCurrentColIndex=0;//拖动后目的列位置索引 function initGrid() { //属性获取 if(defineGridBgColor) {rgbGridBgColor=defineGridBgC}else{rgbGridBgColor="#E1E4EC";} if(defineFirstRowBgColor) {rgbFirstRowBgColor=defineFirstRowBgC}else{rgbFirstRowBgColor="#6699CC";} if(defineFirstColBgColor) {rgbFirstColBgColor=defineFirstColBgC}else{rgbFirstColBgColor="#6699CC";} if(defineCurRowBgColor) {rgbCurRowBgColor=defineCurRowBgC}else{rgbCurRowBgColor="#BBCCDD";} if(defineCurColBgColor) {rgbCurColBgColor=defineCurColBgC}else{rgbCurColBgColor="#BBCCDD";} if(defineCurEditBgColor) {rgbCurEditBgColor=defineCurEditBgC}else{rgbCurEditBgColor="#FFFFFF";} //初始化常量 iColCount=element.rows(0).cells. iRowCount=element.rows. //设置表格样式 element.style.backgroundColor=rgbGridBgC element.border="0"; element.cellSpacing="1"; element.cellPadding="0"; element.width="80%"; element.style.borderLeft="1px solid #000000"; element.style.borderBottom="1px solid #000000"; //设置单元格样式 for(iRow=0;iRow&iRowCiRow++) { for(iCol=0;iCol&iColCiCol++) { element.rows(iRow).cells(iCol).style.borderTop="1px solid #000000"; element.rows(iRow).cells(iCol).style.borderRight="1px solid #000000"; } } //设置头行样式 for(iCol=0;iCol&iColCiCol++) { element.rows(0).cells(iCol).style.backgroundColor=rgbFirstRowBgC } //设置头列样式 for(iRow=1;iRow&iRowCiRow++) { element.rows(iRow).cells(0).style.backgroundColor=rgbFirstColBgC } //设置编辑单元格 for(mIndex=1;mIndex&iRowCmIndex++) { for(nIndex=1;nIndex&iColCnIndex++) { var vText=element.rows(mIndex).cells(nIndex).innerHTML; element.rows(mIndex).cells(nIndex).innerHTML="&div contentEditable=false&"+vText+"&/div&"; element.rows(mIndex).cells(nIndex).children[0].attachEvent("onclick",onEditTrue); element.rows(mIndex).cells(nIndex).children[0].attachEvent("onblur",onEditFalse); } } //绑定列事件 for(iCol=1;iCol&iColCiCol++) { element.rows(0).cells(iCol).attachEvent("onmouseup",onColHeaderMouseDown); } //绑定行事件 for(iRow=1;iRow&iRowCiRow++) { element.rows(iRow).attachEvent("onmouseup",onRowHeaderMouseDown); } //绑定事件方法 element.attachEvent("onmousedown",onMouseDown); element.attachEvent("onmousemove",onMouseMove); element.attachEvent("onmouseup",onMouseUp); element.attachEvent("onselectstart",onSelectStart); } //按下列 function onColHeaderMouseDown() { iCurColIndex=window.event.srcElement.cellI onColHeaderMouseDownColor(iCurColIndex); } //按下行 function onRowHeaderMouseDown() { iCurRowIndex=window.event.srcElement.parentElement.rowI onRowHeaderMouseDownColor(iCurRowIndex); } //启动编辑单元格 function onEditTrue() { var vEditObject=window.event.srcE vEditObject.contentEditable= vEditObject.runtimeStyle.backgroundColor=rgbCurEditBgC } //禁止编辑单元格 function onEditFalse() { var vEditObject=window.event.srcE vEditObject.contentEditable= vEditObject.runtimeStyle.backgroundColor="transparent"; } //Grid鼠标按下 function onMouseDown() { if(window.event.srcElement.tagName.toUpperCase()=="TD") { if(window.event.srcElement.cellIndex==0) { bIsDragRow= iDragHistoryRowIndex=window.event.srcElement.parentElement.rowI } if(window.event.srcElement.parentElement.rowIndex==0) { bIsDragCol= iDragHistoryColIndex=window.event.srcElement.cellI } } } //Grid鼠标移动 function onMouseMove() { if(bIsDragRow==true) { //拖动行模拟层处理. } if(bIsDragCol==true) { //拖动列模拟层处理. } } //Grid鼠标抬起 function onMouseUp() { if(bIsDragRow==true) { if(window.event.srcElement.tagName.toUpperCase()=="TD") { if(window.event.srcElement.cellIndex==0) { iDragCurrentRowIndex=window.event.srcElement.parentElement.rowI if(iDragHistoryRowIndex!=0&&iDragCurrentRowIndex!=0) { moveRow(iDragHistoryRowIndex,iDragCurrentRowIndex); } } } } if(bIsDragCol==true) { if(window.event.srcElement.tagName.toUpperCase()=="TD") { if(window.event.srcElement.parentElement.rowIndex==0) { iDragCurrentColIndex=window.event.srcElement.cellI if(iDragHistoryColIndex!=0&&iDragCurrentColIndex!=0) { moveCol(iDragHistoryColIndex,iDragCurrentColIndex); } } } } bIsDragRow= bIsDragCol= } //Grid鼠标移出 function onMouseOut() { if(bIsDragRow==true) { bIsDragRow= } if(bIsDragCol==true) { bIsDragCol= } } //Grid选择开始 function onSelectStart() {
} //库 //移动行 function moveRow(iFromIndex,iToIndex) { var strFromArray=new Array(iColCount); var strToArray=new Array(iColCount); for(mIndex=0;mIndex&iColCmIndex++) { strFromArray[mIndex]=element.rows(iFromIndex).cells(mIndex).innerHTML; strToArray[mIndex]=element.rows(iToIndex).cells(mIndex).innerHTML; } for(nIndex=0;nIndex&iColCnIndex++) { element.rows(iFromIndex).cells(nIndex).innerHTML=strToArray[nIndex]; element.rows(iToIndex).cells(nIndex).innerHTML=strFromArray[nIndex]; } onRowHeaderMouseDownColor(iToIndex); cellAttachEvent(); } //移动列 function moveCol(iFromIndex,iToIndex) { var strFromArray=new Array(iRowCount); var strToArray=new Array(iRowCount); for(mIndex=0;mIndex&iRowCmIndex++) { strFromArray[mIndex]=element.rows(mIndex).cells(iFromIndex).innerHTML; strToArray[mIndex]=element.rows(mIndex).cells(iToIndex).innerHTML; } for(nIndex=0;nIndex&iRowCnIndex++) { element.rows(nIndex).cells(iFromIndex).innerHTML=strToArray[nIndex]; element.rows(nIndex).cells(iToIndex).innerHTML=strFromArray[nIndex]; } onColHeaderMouseDownColor(iToIndex); cellAttachEvent(); } //行按下变化 function onRowHeaderMouseDownColor(pCurRowIndex) { clearClient(); for(kIndex=1;kIndex&iColCkIndex++) { element.rows(pCurRowIndex).cells(kIndex).bgColor=rgbCurRowBgC } } //列按下变化 function onColHeaderMouseDownColor(pCurColIndex) { clearClient(); for(kIndex=1;kIndex&iRowCkIndex++) { element.rows(kIndex).cells(pCurColIndex).bgColor=rgbCurColBgC } } //清除客户区 function clearClient() { for(mIndex=1;mIndex&iRowCmIndex++) { for(nIndex=1;nIndex&iColCnIndex++) { element.rows(mIndex).cells(nIndex).bgColor="transparent"; } } } //单元格事件绑定 function cellAttachEvent() { for(mIndex=1;mIndex&iRowCmIndex++) { for(nIndex=1;nIndex&iColCnIndex++) { element.rows(mIndex).cells(nIndex).children[0].attachEvent("onclick",onEditTrue); element.rows(mIndex).cells(nIndex).children[0].attachEvent("onblur",onEditFalse); } } } &/script&
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具『Delphi园地』-巧用DBGrid控件的Sort属性实现“点击标题栏自动排序功能”。(改进版)
当前位置:
→ 巧用DBGrid控件的Sort属性实现“点击标题栏自动排序功能”。(改进版)
巧用DBGrid控件的Sort属性实现“点击标题栏自动排序功能”。(改进版)
日期: 作者:大富翁aricyoung 人气: 查看:[
曾看见CSDN文档中有介绍到:通过ADOQuery或其它数据集组件的Sort属性配合DBGrid的OnTitleClick事件,可以方便地实现此功能。因为Sort属性可以让活动数据集按指定的字段进行排序,也可以选择排序方式(升序/降序)。这个功能的确很实用。(http://blog.csdn.net/jlee084/archive//223284.aspx)。我改进了一下这功能,在单击标题后分别在标题加上三角(▲)和倒三角形(▼)表示当前排序方式为升序和降序;procedure TForm1.DBGrid1TitleClick(Column: TColumn); var I,ii:I cStr: c:TC begin for ii:=0 to TDBGrid(Column.Grid).Columns.Count-1 do begin c:=TDBGrid(Column.Grid).Columns[ii]; cStr:=c.Title.C if (pos('▲',cStr)=1) or (pos('▼',cStr)=1) then begin Delete(cStr,1,2); c.Title.Caption:=cS
for i:= 1 to DBGrid1.Columns.Count do begin //恢复所有标题字体为默认 DBGrid1.Columns[i-1].Title.Font.Color := clWindowT DBGrid1.Columns[i-1].Title.Font.Style := [];
if ADOQuery1.Sort&&(Column.FieldName+' ASC') then //判断原排序方式 begin ADOQuery1.Sort := Column.FieldName+' ASC'; //Column.Title.Font.Color := clR //改变标题行字体为红色,表示当前的排序方式为升序 Column.Title.Font.Style := [fsBold]; Column.Title.Caption:='▲'+Column.Title.C //标题加上三角形表示当前排序方式为升序; end else begin ADOQuery1.Sort := Column.FieldName+' DESC'; //Column.Title.Font.Color := clB //改变标题行字体为蓝色,表示当前的排序方式为降序 Column.Title.Font.Style := [fsBold]; Column.Title.Caption:='▼'+Column.Title.C //标题加上倒三角形表示当前排序方式为降序;
(出处:)
相关文章:
All Rights ReservedDBGrid控件使用技巧【转】
Builder是著名的快速可视化开发工具(RAD)之一,它和Delphi共用可视化类库VCL,由于其具有C++语言良好的可操作性,可以用来编写出高效率、高质量的应用程序代码,因而越来越受广大程序员的欢迎。
Builder具有强大的数据操作能力,其集成开发环境(IDE)的控件板给用户提供了大量的数据访问控件,通过对有关数据库控件属性进行适当设置,合理地引用其方法来控制事件,能极大地方便数据库应用程序的创建。
  C++ Builder控件板上提供了数据库应用程序开发中所要使用的控件,其中,数据访问页(Data Access
Page)控件板上的控件用于直接访问数据库中的数据库表,而数据控制页(Data Control
Page)控件板上的控件用来与用户交互、显示、修改数据库中的数据,DBGrid就是其中一种功能强大的数据控制控件,它用于全屏幕显示和编辑数据库表中的记录,表现为网格的形式。本文主要介绍DBGrid控件使用过程中的一些技巧。
  实现动态数据排序
  DBGrid控件不具备访问磁盘数据库的能力,它是必须通过DataSource控件来实现的。其属性DataSource指向某一DataSource控件,而DataSource控件的DataSet属性指向的数据集可以是TTable或TQuery控件。通过使用TQuery控件动态编程,我们可以实现程序运行时单击DBGrid控件的标题部分,数据即可按选定字段排序的功能。具体实现过程如下:
  新建工程,在Form1上拖放TQuery、TDatasource 和
TDbGrid控件,Name属性分别是Query1、Datasource1和DbGrid1,然后将它们关联起来,Query1
的DatabaseName属性指向DBDEMOS,DbGrid1的Datasource属性设为Datasource1,Datasource1的Dataset属性值设为Query1。在Form1的CPP文件对应的头文件中声明AnsiString型变量QuerySQL,用于存放SQL语句内容。在Form1的OnActivate事件中检索数据,编写如下代码:
  void __fastcall TForm1::FormActivate(TObject Sender)
   QuerySQL = "SELECT  FROM Customer.DB";
   Query1->SQL->Add(QuerySQL);
   Query1->Open();
  使DbGrid1控件显示的数据排序的关键是在DbGrid1的OnTitleClick事件中编程改变Query1的SQL语句内容,程序如下:
  void __fastcall TForm1::DBGrid1TitleClick(TColumn Column)
   AnsiS
   str= Column->FieldN
  //获取鼠标点击数据栏的字段名称
   Query1->DisableControls();
   Query1->Close();
   Query1->SQL->Clear();
   Query1->SQL->Add(QuerySQL);
   Query1->SQL->Add("ORDER BY "+str);
   Query1->Open();
   DBGrid1->Columns->RestoreDefaults();
   //使鼠标点击的数据栏的标题改变颜色
   for (int i = 0; i < i < Query1->FieldC i++)
   //遍历Query1的字段,判断其是否是鼠标点击的字段
   if (Query1->Fields->Fields[i]->FieldName ==str)
  DBGrid1->Columns->Items[i]->Title->Font->Color= clR
   DBGrid1->Columns->Items[i]->Title->Alignment=
taC//标题居中
   Query1->EnableControls();
  在数据栏中显示图像
  使用DBGrid1控件来全屏显示编辑数据时,为了使界面生动活泼,我们希望能根据字段枚举数值(其取值通常为几个特定值)的不同显示不同的图像。
  我们可以在DBGrid控件的OnDrawColumnCell事件中编写代码来增强DBGrid控件的显示效果,如果其DefaultDrawing属性为true,DBGrid控件在OnDrawColumnCell事件响应前按默认效果显示,然后以此为基础执行OnDrawColumnCell事件的代码。需要完全取代DBGrid控件的显示效果时,可将其DefaultDrawing属性设为false,并在OnDrawColumnCell事件中编写控制显示效果的脚本。如果希望某些列产生特定效果,可以在OnDrawColumnCell事件中调用DefaultDrawColumnCell方法,然后修正特定列的输出效果。以下示例是在DBGrid控件数据栏中显示图像效果的程序。
  新建工程,在Form1上拖放TTable、TDatasource
、TDbGrid和TImageList控件,Name属性分别是Table1、Datasource1、DbGrid1和ImageList1,然后将它们关联起来,Table1
的DatabaseName属性指向DBDEMOS(该别名指代C++
Builder自带的例程数据库表)、TableName属性为Clients.dbf、Datasource1的Dataset属性值为Table1、DbGrid1的Datasource属性等于Datasource1。使用DbGrid1的列编辑器让DbGrid1仅显示Last_Name、First_Name、Risk_Level和
Occupation四个字段,再设置DbGrid1的DefaultDrawing属性为false,然后设置ImageList1存放向下、向上、向左的三种箭头图像。DBGrid1的On
DrawColumnCell事件代码如下:
  void __fastcall TGridDrawForm::DBGrid1DrawColumnCell(TObject
Sender,
   const TRect &&Rect, int DataCol,
TColumn Column,TGridDrawState State)
  if (DBGrid1->Columns->Items[DataCol]->FieldName ==
"RISK_LEVEL")
   DBGrid1->Canvas->FillRect(Rect);
   if (DBGrid1->Columns->Items[DataCol]->Field->AsString ==
   {//字段值为“LOW”,绘制向下的箭头
ImageList1->Draw(DBGrid1->Canvas,Rect.Left+4,Rect.Top,0,True);
   else if (DBGrid1->Columns->Items[DataCol]->Field->AsString ==
   {//字段值为“MED”,绘制向左的箭头
ImageList1->Draw(DBGrid1->Canvas,Rect.Left+4,Rect.Top,1,True);
   {//否则绘制向上的箭头
ImageList1->Draw(DBGrid1->Canvas,Rect.Left+4,Rect.Top,2,True);
   DBGrid1->DefaultDrawColumnCell(Rect,DataCol,Column,State);
  当绘制DBGrid时,绘制屏幕上当前可见行的每个数据单元都调用上述事件过程。DataCol用于显示DBGrid的Columns属性的顺序。根据DataCol值可以确定将绘制的数据单元的栏目名称。此例中,如果栏目的字段不是“Risk_Level”则调用DefaultDrawColumnCell方法,使其成默认的显示效果。反之,则先调用FillRect方法清除背景,然后根据该字段值的不同,调用ImageList的Draw方法,实施对象是DBGrid控件的画布对象,Rect中参数Left和Top值决定了绘制坐标的位置,图像列表中不同的值决定了产生图像的不同。
  将当前行以不同颜色显示
DBGrid控件中当前的数据通常是用蓝色背景显示的,有时我们为了达到提示及操作界面美化方面的要求,希望能将DBGrid控件显示的数据用不同的颜色背景显示,比如红色。我们只需将DBGrid控件的Option属性中的dgRowSelect值设为true,在DBGrid控件的OnDrawColumnCell事件中编写程序,根据某行是否有方格被选中或是否处于活动状态来改变DBGrid控件中画布Canvas的Brush对象的颜色值,然后调用DefaultDrawColumnCell方法。
   以前面实现动态数据排序的程序为基础,在DBGrid1的OnDrawColumnCell事件中编写如下代码:
  void __fastcall TForm1::DBGrid1DrawColumnCell(TObject Sender,
const TRect &&Rect, int DataCol,
TColumn Column, TGridDrawState State)
  {//如果某行有方格被选中,则置以红色背景,否则设成白色
   if (State.Contains(gdFocused) ||
State.Contains(gdSelected))
   DBGrid1->Canvas->Brush->Color=clR
   DBGrid1->Canvas->Brush->Color= clW
   DBGrid1->DefaultDrawColumnCell(Rect,DataCol,Column,State);
  我们同样可以根据DBGrid控件显示的数据行某个字段值的不同,应用OnDrawColumnCell事件改变该行数据的字体颜色或背景颜色。
  禁止控件自动添加空行
  使用DBGrid控件全屏显示数据记录时,若DBGrid控件Option属性的dgEditting值设置是true,或者DBGrid控件的各个显示字段Column的ReadOnly属性值是false时,当达到最后一条记录行并继续敲击键盘下箭头键,DBGrid控件会增加新行,这样可能会引起数据输入问题,大部分时间我们并不希望如此。
  为解决此问题,我们可以将DBGrid控件Option属性的dgEditting值设置为false,或者将DBGrid控件的显示字段Column的ReadOnly属性值设置为true,但是会产生DBGrid控件显示数据不可编辑的问题,我们可以用下面的两种方法来加以解决:
  1.可以编辑DBGrid控件引用的DataSource控件对应的数据集Table的BeforeInsert事件,只需在其中写入Abort即可。代码如下:
  void __fastcall TForm1::Query1BeforeInsert(TDataSet
DataSet)
  2.通过DBGrid1的onKeydown事件判别是否按了“下箭头”键和Table1的记录是否为最末记录,人为地改变当前记录行,DBGrid控件显示数据的当前行与数据集的当前行是一致的。
  void __fastcall TForm1::DBGrid2KeyDown(TObject Sender, WORD
   TShiftState Shift)
  if (Key = VK_DOWN)//判断按键是否为下箭头键
   {//是,使Table1记录指针下移一条记录,再判断是否是表尾
   Table1->DisableControls() ;
   Table1->Next() ;
   if (Table1->Eof)
   { Key = 0 ;}
  //是表尾,赋Key值为0,不添加空行
   {Table1->Prior();} ;
  //将表的记录指针回移到原位置
   Table1->EnableControls() ;
  以上,笔者谈了DBGrid控件的几种使用技巧,其实程序开发中有许多技巧能够使应用程序更好地满足用户的需求,利用不同开发工具的程序开发人员可以互相借鉴,使开发的应用程序更加精致。
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。}

我要回帖

更多关于 车载音响电源接线图解 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信