天天看點

60個資料視窗技巧

1.如何讓存儲檔案目錄的列,顯示圖檔? 答:選擇對應的column的display as picture屬性為true
 
2、如何複制grid類型的所選擇的行的資料到系統剪切闆?
答:string ls_selected
ls_selected=dw_1.Object.DataWindow.Selected.Data
clipboard(ls_selected)
3、如何複制graph風格的datawindow中的圖形到剪切闆?
答:dw_1.clipbord("gr_1")
4、如何設定的DW底色?
在DW的editsource中改變color的值
5、如何将Grid風格改成自由格式?
在DW的editsource中将processing=1的1改為0
6、要建立一個表A但風格和現有表格B風格一樣,怎麼将A表快速設定成表B風格?
複制B表C,在C表的DW中的editsource中将表名和字段名改成A表的,即可
7、如何實作gird風格的datawindow的多欄表頭?
答:添加 text到header帶區,并設定band屬性為foreground儲存,edit source 修改text的x和width屬性表達式如下:
x="100~t integer(describe('firstcol.x')" width="100~tinteger(describe('lastcol.x')) - integer(describe('firstcol.x')) +integer(describe('lastcol.width'))
8、如何過濾dddw編輯風格的顯示值為指定值的記錄?
答:dw_1.setfilter("lookupdisplay('column_name')='"+ls_display_value_your+"'")
dw_1.filter()
9、如何設定datawindow的某一列為空?
答:string ls_temp[]
setnull(ls_temp)
dw_1. O B J E C T.columnname.primary.current=ls_temp
10、如何設定datawindow的單雙行不同顔色間隔?
答:在detail帶區的color屬性表達式中寫上if(mod(getrow(),2)=1 ,rgb(255,0,0),rgb(0,255,0)),如果是目前行以第三種顔色表示,表達式如下:if(getrow()=current(),rgb(255,0,0),if(mod(getrow(),2)=1 ,rgb(0,0,255),rgb(0,255,0)))
11、如何擷取指定名稱的datawindow O B J E C T?
答:DWObject ldwo_use,ldwo_abc
ldwo_use = dw_1.Object
ldwo_abc = ldwo_use.__get_attribute("t_1",FALSE)//t_1為datawindow中text對象的名稱
12、如何使用datawindow的查詢模式?
答:dw_1.Object.DataWindow.QueryMode='yes'将datawindow改變為查詢模式後,接收使用者的輸入,再使用一下代碼擷取結果:
dw_1.accepttext()
dw_1.retrieve()
13、如何縮放datawindow的列印大小?
答:dw_1. O B J E C T.datawindow.zoom=150 or dw_1. O B J E C T.datawindow.zoom=75
14、如何在已過濾後的資料基礎上對datawindow進行過濾?
答:dw_1.setfilter(dw_1.describe("datawindow.table.filter")+your_join+your_new_filter)
dw_1.filter()
15、如何在datawindow中顯示動态時間?
答:建立一個計算域,表達式為string(datetime(today(),now()),'yyyy年mm月dd日 hh點mm分ss秒'),同時設定datawindow的屬性dw_1.Object.DataWindow.Timer_Interval=500
16、如何讓帶用title bar的datawindow控件的标題欄誠活動視窗的顔色?
答:外部函數定義:
funcation logn SetActiveWindow(long hwnd ) Library "user32.dll"
datawindow控件的clicked事件代碼:
setactivewindow(handle(this))
17、如何設定datawindow的目前行訓示圖示?
答:在datawindow中建立一個計算列,expression為'',并将該計算列移動為datawindow的第一個列,在datawindow控件的
rowfocuschanged事件中寫入代碼:
SetRowFocusIndicator(hand!)或setrowfucsindicator(p_1)//p_1為視窗上的picture控件名
18、如何通過代碼打開dddw?
答:定義外部函數引用聲明
SUBROUTINE keybd_event( int bVk, int bScan, int dwFlags, int dwExtraInfo) LIBRARY "user32.dll"
代碼如下:
[constant integer VK_F4 = 115
dw_1.SetFocus()
dw_1.SetColumn( "dept_head_id" ) //設定目前dddw
keybd_event( VK_F4,0,0,0 ) // 按下F4鍵
keybd_event( VK_F4,0,2,0 ) // 釋放F4鍵
19、如何列印datawindow的内容到檔案中?
答: dw_1. O B J E C T.datawindow.print.fileName ="c:\temp.prn"
dw_1.print()
20、如何設定dddw的初始值?
答:dw_1. O B J E C T.columnname.Initial="your_initial_value"
21、如何隻顯示不同的資料?
答:dw_1.filter("isnull(columnname[-1]) and columnname<>columnname[-1]")
dw_1.filter()
22、如何讓帶有title bar的datawindow不可以移動?
答:在datawindow的自定義事件ue_nchittest(pbm_nchittest)中寫入如下代碼:
return 1
23、如何在N-UP顯示風格中建立基于第N欄中的列的計算列?
答:如column有兩列,number和price ,并顯示為兩欄,則第一欄的cost計算列的expression為number*price,第二欄的cost_1計算列的expression為number[1]*price[1]
24、如何清空ddlb或edit.codetable中項目?
答:dw_1.Object.columnname.Values=""
25、如何實作指定的column的字型旋轉90度?
答:dw_1. O B J E C T.columnname.font.Escapement ="900"
26、如何擷取datawindow的sql代碼?
答: 可以通過以下四種方法擷取sql代碼:
string szselect
szselect=dw_1.describe("datawindow.table.select")
szselect=dw_1.describe("datawindow.table.sqlselect")
szselect=dw_1.describe("datawindow.table.select.attribute")
szselect=dw_1.getsqlselect() 
27、如何擷取datawindow對象占有的虛拟存儲的容量?
答:使用datawindow.storage屬性
舉例:在datawindow控件的retrieverow事件中,寫如如下代碼:
long lstorage
lstorage=long(dw_1. O B J E C T.datawindow.storage)
if lstorage>50000 then dbcancel()
28、如何控制列印橫向:
dw_control. O B J E C T.datawindow.print.orientation= 1

29、如何進行預覽:
dw_control. O B J E C T.datawindow.print.preview = "yes"
30、如何連續在同一張紙列印兩個資料視窗?
答:dw_1. O B J E C T.datawindow.print.filename="temp.prn"
dw_2. O B J E C T.datawindow.print.filename="temp.prn"
dw_1.print()
dw_2.print()
31、如何将pb9.0 的datawindow轉化為pb 8.0版本的datawindow?
答:edit source 将release 9;改為release 8;
并删除以下内容:
print.printername=""
print.canusedefaultprinter=yes
print.cliptext=no print.overrideprintjob=no
hidegrayline=no
encodeselflinkargs="1"
export.xml(headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0 )
import.xml()
export.pdf(method=0 distill.custompostscript="0" xslfop.print="0" )
32、如何設定datawindow分組後每個分組中的記錄号?
答:建立一個計算列,expression為 getrow() - first(getrow() for group 1)+1
33、如何實作在datawindow中隻有新增的行,才可以編輯?
答:在所有的column的protect屬性表達式中寫入以下表達式:
if(isrownew(),'0','1')
34、儲存datawindow資料到excel中
// ... Init docname 
// ... GetFileOpenName or any other method 

if dw_1.SaveAs(docname, HTMLTable!, True) = -1 then 
MessageBox("Warning", "Unable to export data. Error writing to file!", Exclamation!) 
return 
end if 


// Convert HTML file to Excel native format 
OLEObject excel 
excel = CREATE OLEObject 
if excel.ConnectToObject(docname) = 0 then 
excel.application.DisplayAlerts = FALSE 
excel.application.workbooks(1).Parent.Windows(excel.application.workbooks(1).Name).Visible = True 
excel.application.workbooks(1).saveas(docname, 39) 
excel.application.workbooks(1).close() 
end if 

DESTROY excel 
// done 

35、除了循環以外,有沒有更好的方法統計資料視窗中處于選中狀态的行數?
一般習慣于使用循環來統計資料視窗中處于選中狀态的行數,有沒有更好的方法? 

其實此問題在應用上用處不大,讨論一下,活躍一下思維還是有好處的。 

方法一: 
long ll_Selected 

ll_Selected = long(dw_1.describe("evaluate('sum( if(IsSelected(), 1, 0) for all)',1)")) 

方法二: 
long ll_Selected 

ll_Selected = long(dw_1.describe("evaluate('count(IsSelected() for all)',1)"))

方法三:
upperbound(dw_1.Object.Data.Selected)
36、問:怎麼讓PB隻列印目前記錄,是用Free格式制作的資料視窗! 

答: 
DataStore ldt_temp 
long ll_Row , ll_Rows 
ll_Rows = dw_XX.Rowcount() 
If ll_Rows = 0 Then GoTo the_end 
If ll_Rows = 1 Then 
dw_XX.Print() 
GoTo the_end 
End if 
dw_XX.SetRedraw(False) 
ldt_temp = Create DataStore 
ldt_temp.DataObject = dw_XX.DataObject 
ll_Row = dw_XX.GetRow() 
dw_XX.RowsMove(1 , ll_Rows , Primary! , ldt_temp , 1 , Primary!) 
ldt_temp.RowsMove(ll_Row , ll_Row , Primary! , dw_XX , 1 , Primary!) 
dw_XX.Print() 
dw_XX.RowsMove(1 , 1 , Primary! , ldt_temp , ll_Row , Primary!) 
ldt_temp.RowsMove(1 , ll_Rows , Primary! , dw_XX , 1 , Primary!) 
Destroy ldt_temp 
dw_XX.SetRedraw(True) 
the_end: 
//隻用将上述腳本拷入到列印部分即可,dw_XX為被列印的free型資料視窗,該方法可保證dw_XX中的資料在列印前後包括sort等屬性均不發生任何改變,但效率較低,不宜用在資料量太大的資料視窗中,當然,考慮到列印本身速度就比較慢,是以3000行資料是可以采用這種方法并讓使用者接受的。若在同一視窗上存在與dw_XX共享的grid資料視窗并且與dw_XX同時顯示,則需要與dw_one一起SetRedraw()


37、怎樣将資料視窗(free格式)中的内容轉成word文檔
答:給你兩個函數: 
(1)、輔助函數 
$PBExportHeader$f_cncharnum.srf 
$PBExportComments$得到字元串中漢字或者雙位元組的個數 
global type f_cncharnum from function_ O B J E C T 
end type 

forward prototypes 
global function integer f_cncharnum (string aString) 
end prototypes 

global function integer f_cncharnum (string aString); 
//函數名: f_cncharnum 
//用途: 傳回一個字元串中漢字的個數 
//輸入: aString - string, 給定的字元串 
//傳回值: li_num - Integer, 給定的字元串中漢字的個數 
//注意: 1. 此方法基于漢字的國标漢字庫區位編碼的有效性,不符合此編碼的系統此函數無效! 
// 2. 若漢字串含有非漢字字元,如圖形符号或ASCII碼,則這些非漢字字元将保持不變. 
//例如: li_ret = f_cncharnum("擺渡人ferryman") li_ret = 3 

string ls_ch //臨時單元 
string ls_SecondSecTable //存放所有國标二級漢字讀音 
integer li_num = 0 //傳回值 
integer i,j 

For i = 1 to Len(aString) 
ls_ch = Mid(aString,i,1) 
If Asc(ls_ch) >= 128 then //是漢字 
li_num++ 
i = i+1 
End if 
Next 

Return li_num 

end function 

--------------------------------------------------------------- 

(2)、轉到WORD 
$PBExportHeader$f_outputtoword_new.srf 
global type f_outputtoword_new from function_ O B J E C T 
end type 

forward prototypes 
global function integer f_outputtoword_new (datawindow adw) 
end prototypes 

global function integer f_outputtoword_new (datawindow adw); 
//函數名:f_outputtoword_new 
//輸入: adw - datawindow,指定的資料視窗 
//傳回值: Integer 
constant integer ppLayoutBlank = 12 
OLEObject ole_ O B J E C T 
ole_ O B J E C T = CREATE OLEObject 

integer li_ret 

li_ret = ole_ O B J E C T.ConnectToObject("","word.application") 
IF li_ret <> 0 THEN 
//如果Word還沒有打開,則建立。 
li_ret = ole_ O B J E C T.ConnectToNewObject("word.application") 
if li_ret <> 0 then 
MessageBox('OLE錯誤','OLE無法連接配接!錯誤号:' + string(li_ret)) 
return 0 
end if 
ole_ O B J E C T.Visible = True 
END IF 

long ll_colnum,ll_rownum 
constant long wdWord9TableBehavior = 1 
constant long wdAutoFitFixed = 0 
constant long wdCell = 12 
string ls_value 
pointer oldpointer 

oldpointer = SetPointer(HourGlass!) 

string ls_ O B J E C Ts,ls_obj,ls_objs[],ls_objtag[] 
long ll_pos,ll_len,ll_num = 0 

ls_ O B J E C Ts = trim(adw.Describe('datawindow.Objects')) 

do while (pos(ls_ O B J E C Ts,"~t") > 0) 
ll_pos = pos(ls_ O B J E C Ts,"~t") 
ll_len = ll_pos - 1 
ls_obj = left(ls_ O B J E C Ts,ll_len) 
if (adw.Describe(ls_obj + '.type') = 'column' or & 
adw.Describe(ls_obj + '.type') = 'compute') and & 
(adw.Describe(ls_obj + '.band') = 'detail') and (ls_obj <> "asd") then 
ll_num += 1 
ls_objs[ll_num] = ls_obj 
ls_objtag[ll_num] = adw.Describe(ls_obj + '.tag') 
end if 
ls_ O B J E C Ts = right(ls_ O B J E C Ts,len(ls_ O B J E C Ts) - ll_pos) 
loop 

//得到資料視窗資料的列數與行數(行數應該是資料行數 + 1) 
ll_colnum = ll_num 
ll_rownum = adw.rowcount() + 1 

ole_ O B J E C T.Documents.Add() 
ole_ O B J E C T.ActiveDocument.Tables.Add(ole_ O B J E C T.Selection.Range, ll_rownum, ll_colnum) 

string ls_colname 
integer i,j,k 

for i = 1 to ll_colnum 
//得到标題頭的名字 
ls_value = ls_objtag 
ole_ O B J E C T.Selection.TypeText(ls_value) 
for k = 1 to f_cncharnum(ls_value) 
ole_ O B J E C T.Selection.TypeBackspace() 
next 
ole_ O B J E C T.Selection.MoveRight(wdCell) 
next 

adw.setredraw(false) 
ole_ O B J E C T.Selection.MoveLeft(wdCell) 
string column_name 
for i = 2 to ll_rownum 
for j = 1 to ll_colnum 
column_name = ls_objs[j] 
if adw.Describe(column_name + '.type') = 'column' then 
ls_value = adw.Describe("Evaluate('LookupDisplay("+column_name+")',"+string(i - 1)+")") 
end if 
if adw.Describe(column_name + '.type') = 'compute' then 
ls_value = adw.Describe("Evaluate('" + adw.Describe(column_name + '.expression') + "',"+string(i - 1)+")") 
end if 
ole_ O B J E C T.Selection.MoveRight(wdCell) 
ole_ O B J E C T.Selection.TypeText(ls_value) 
//for k = 1 to f_cncharnum(ls_value) 
//ole_ O B J E C T.Selection.TypeBackspace() 
//next 
next 
next 
adw.setredraw(true) 

constant long wdFormatDocument = 0 

SetPointer(oldpointer) 
//儲存建立的文檔 
if messagebox("儲存","文檔已經成功完成,是否儲存?",Question!,YesNo!) = 1 then 
string docname, named 
integer value 

value = GetFileSaveName("選擇檔案",docname, named, "DOC","Doc Files (*.DOC), *.DOC") 

IF value = 1 THEN 
ole_ O B J E C T.ActiveDocument.SaveAs(docname, 0,False,"",True,"",False,False,False, False,False) 
end if 

end if 
//斷開OLE連接配接 
Ole_Object.DisConnectObject() 
Destroy Ole_Object 

return 1 
end function 

38、字段如何自動換行的同時且自動高度?
答:将資料視窗中相應列的auto horz scroll 為不選中,選中autosize height 
将detail的autosize height選中。在資料視窗retrieve 後調用下面函數即可 

uf_set_text(datawindow adw_content,string 
as_columns,boolean,ab_ignoreblank) 
/************************************************************* 
describe: 在資料視窗adw_content中,在as_columns中包含的列中插入空格 
args: 
as_columns 要操作的多個列,列間用逗号隔開 
*************************************************************/ 
if (not isvalid(adw_content)) or isnull(as_columns) or len(as_columns)<1 or isnull(ab_ignoreblank) then return -1 

n_cst_string lnv_string 
string ls_column[] , ls_width ,as_source,as_replaced ,ls_temp 
int li_upperbound , li_width , li_column , li_fontWidth, li_counter 
long ll_rowcount , ll_row , ll_totalstep 
int li_yield 

lnv_string.of_parsetoarray(as_columns,',',ls_column) 
li_upperbound = upperbound(ls_column) 
ll_rowcount = adw_content.rowcount() 
if li_upperbound<1 or ll_rowcount<1 then return -1 

openwithparm(w_waiting,this) 
ib_cancel = false 
iw_frame.enabled = false 
ll_totalstep = ll_rowcount * li_upperbound 
w_waiting.uf_register(ll_totalstep) 
for li_column = 1 to li_upperbound 
ls_width = adw_content.describe(ls_column[li_column]+".width") 
li_width = integer(ls_width) 
if ls_width='!' or ls_width='?' or li_width=0 then 
continue 
end if 
//ls_temp = adw_content.describe(ls_column[li_column]+".Font.property { = 'width' }") 
//messagebox(ls_column[li_column]+".Font.property { = 'width' }",ls_temp) 
//return 1 
li_fontwidth = 27 
li_counter = li_width / li_fontWidth 

for ll_row=1 to ll_rowcount 
if ib_cancel then 
iw_frame.enabled = true 
return 0 //pressed cancel button 
end if 
as_source = adw_content.getitemstring(ll_row,ls_column[li_column]) 
as_replaced = uf_insertstring(as_source,li_counter,' ',false) 
if as_replaced<>as_source then 
adw_content.setitem(ll_row,ls_column[li_column],as_replaced) 
end if 
w_waiting.uf_stepit() 
next 
next 
close(w_waiting) 
iw_frame.enabled = true 

return 1 

39、如何動态外部建立資料視窗?
答:首先制作一個自己想動态得到的資料視窗,然後将該資料視窗導出,看看文法,這樣你就了解了這種資料視窗的生成文法了! 

--------------------------------------------------------------- 

dw_1.create() 
可以參考幫助 以及 srd檔案(資料視窗導出檔案) 
--------------------------------------------------------------- 

動态資料窗建立原理及實作 

在實際應用中,經常需要根據使用者需求來動态建立資料窗,一般方法是這樣的。 

在一個window中加入一個資料窗控件,如dw_new,但是該資料窗沒有data O B J E C T,(空白的) 
就可以用以下文法來建立: 
dw_new.create(ls_syntax,ls_error) // 建立文法,錯誤資訊 
ls_syntax可以用以下三種方法來形成: 

一、動态由sql文法建立: 

// 連接配接到pb的example資料庫 
string ls_sql,ls_syntax,ls_error 
ls_syntax = 'select * from department' 
ls_syntax = sqlca.SyntaxFromSQL(ls_sql,'style(type=grid)',ls_error) 
if len(ls_error) >0 then 
messagebox('Error','SyntaxFromSQL Error:~r'+ls_error) 
else 
dw_new.create(ls_syntax,ls_error) 
if len(ls_error) >0 then 
MessageBox("Error", "Create have these errors: ~r" + ls_error) 
else 
dw_new.settrans O B J E C T(sqlca) 
dw_new.retrieve() 
end if 
end if 

二、由另一個資料窗的syntax來建立 

string ls_syntax,ls_error 
ls_syntax = dw_test.describe('datawindow.syntax') 
dw_new.create(ls_syntax,ls_error) 
if ls_error <> '' then 
messagebox('Create Error',ls_error) 
else 
dw_new.settrans O B J E C T(sqlca) 
dw_new.retrieve() 
end if 

三、讀取psr檔案來建立 

樣例 
string ls_syntax,ls_error,ls_ret 
ls_ret = char(13)+char(10) //Enter鍵 
int li_fileNum 
long li_length 
li_FileNum = FileOpen("efef.psr",Streammode!, read!, shared!, Replace!) 

// 以下是pb5的代碼 
if li_filenum >0 then 
FileSeek(li_FileNum, 158, FromBeginning!) 
li_length = fileRead(li_filenum,ls_syntax) 
end if 
fileclose(li_filenum) 
if li_length = 0 then return 
ls_syntax = "release 5;"+ls_ret+ls_syntax 

//截掉ls_syntax中的資料部分,5.0以"sparse(names="dept_name?) "作為參考位置 
//6.0以html(作為參考位置 

long pos1,pos2 
pos1 = pos(ls_syntax,'sparse(names="',1) 
pos2 = pos(ls_syntax,'"',pos1 +16) 
ls_syntax = left(ls_syntax,pos1) + mid(ls_syntax,pos1 +1,pos2 - pos1 +1) 

dw_New.create(ls_syntax,ls_error) 

if ls_error <> '' then 
messagebox('Create Error',ls_error) 
else 
dw_new.settrans O B J E C T(sqlca) 
dw_new.retrieve() 
end if 

global type f_createextenddw from function_ O B J E C T 
end type 

forward prototypes 
global function string f_createextenddw (ref datawindow dw, string cols[]) 
end prototypes 

global function string f_createextenddw (ref datawindow dw, string cols[]);string sql_dw_general, sql_dw_columns_type, sql_dw_headers_conf, sql_dw_columns_conf, ls_errors 
int i 
long ll_colcount 
string ls_colnametype 
string ls_colname,ls_coltype 
long ll_pos 

ll_colcount = upperbound(cols) 

//generals 
sql_dw_general = "release 8;" & 
+ "datawindow(units=0 timer_interval=0 color=16777215 processing=0 print.documentname=" + char(34) + "" + char(34) + " print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.prompt=no print.buttons=no print.preview.buttons=no )" & 
+ "header(height=72 color=" + char(34) + "536870912" + char(34) + " )" & 
+ "summary(height=0 color=" + char(34) + "536870912" + char(34) + " )" & 
+ "footer(height=0 color=" + char(34) + "536870912" + char(34) + " )" & 
+ "detail(height=84 color=" + char(34) + "536870912" + char(34) + " )" 


//列及類型 
sql_dw_columns_type = "table(" 
FOR I=1 to ll_colcount 
ls_colnametype = trim(cols) 
ls_colname = right(ls_colnametype,len(ls_colnametype) - 1) 
ls_coltype = left(ls_colnametype,1) 
choose case upper(ls_coltype) 
case 'C' 
ls_coltype = 'char(100)' 
case 'D' 
ls_coltype = 'date' 
case 'N' 
ls_coltype = 'decimal(6)' 
case else 
ls_coltype = 'char(100)' 
end choose 
//ls_coltype = 'char(100)' 
//列及類型 
sql_dw_columns_type= sql_dw_columns_type + "column=(type=" +ls_coltype+" updatewhereclause=no name=" + ls_colname + " dbname=" + char(34) + ls_colname + char(34) + " ) " 

//列标題 
sql_dw_headers_conf = sql_dw_headers_conf + "text(band=header alignment=" + char(34) + "2" + char(34) + " text=" + char(34) + ls_colname + char(34) + " 6" + char(34) + " color=" + char(34) + "16711680" + char(34) + " x=" + char(34) + string( ((i - 1) * 588) + 5) + char(34) + " y=" + char(34) + "4" + char(34) + " height=" + char(34) + "64" + char(34) + " width=" + char(34) + "574" + char(34) + " name=" + ls_colname + "_t font.Arial" + char(34) + " font.height=" + char(34) + "-10" + char(34) + " font.weight=" + char(34) + "400" + char(34) + " font.family=" + char(34) + "2" + char(34) + " font.pitch=" + char(34) + "2" + char(34) + " font.charset=" + char(34) + "0" + char(34) + " background.mode=" + char(34) + "2" + char(34) + " background.color=" + char(34) + "12632256" + char(34) + " )" 

//列屬性 
sql_dw_columns_conf = sql_dw_columns_conf + "column(band=detail id=" + string(i) + " alignment=" + char(34) + "1" + char(34) + " tabsequence=" + string(i) + "0 2" + char(34) + " color=" + char(34) + "0" + char(34) + " x=" + char(34) + string( ((i - 1) * 588) + 5) + char(34) + " y=" + char(34) + "4" + char(34) + " height=" + char(34) + "76" + char(34) + " width=" + char(34) + "579" + char(34) + " format=" + char(34) + "[general]" + char(34) + " name=" + ls_colname + " edit.limit=0 edit.case=any edit.autoselect=yes edit.autohscroll=yes font.Arial" + char(34) + " font.height=" + char(34) + "-10" + char(34) + " font.weight=" + char(34) + "400" + char(34) + " font.family=" + char(34) + "2" + char(34) + " font.pitch=" + char(34) + "2" + char(34) + " font.charset=" + char(34) + "0" + char(34) + " background.mode=" + char(34) + "1" + char(34) + " background.color=" + char(34) + "536870912" + char(34) + " )" 

NEXT 

sql_dw_columns_type= sql_dw_columns_type + " )" 

sql_dw_columns_conf = sql_dw_columns_conf + "htmltable(1" + char(34) + " cellpadding=" + char(34) + "0" + char(34) + " cellspacing=" + char(34) + "0" + char(34) + " generatecss=" + char(34) + "no" + char(34) + " nowrap=" + char(34) + "yes" + char(34) + ")" 

//MESSAGEBOX('',sql_dw_general + sql_dw_columns_type + sql_dw_headers_conf + sql_dw_columns_conf) 
dw.Create(sql_dw_general + sql_dw_columns_type + sql_dw_headers_conf + sql_dw_columns_conf , ls_errors) 

return(ls_errors) 
end function 

40、如何讓datawindow的heade帶區r的内容隻列印一次?
答:a、制作兩個資料視窗,第一個有表頭,第二個沒有。 
b、用第一個有表頭的資料讀取資料庫中的資料 
c、列印有表頭的資料視窗中的第一頁,記住結束行号 
d、将從結束行号開始的所有資料複制到第二個資料視窗中 
e、列印第二個資料視窗

41、交叉報表在retrieve後,其datawindow的寬度怎麼獲得啊?
答://============================= 
// [PUBLIC] Function wf_settitle_length 在 w_search_report inherited from window 
//---------------------------- 
// 說明:設定表頭長度 
//---------------------------- 
// 參數1:[reference] datawindow adw_1 
// 說明:報表DW 
//-------------------------------------- 
// 傳回: (INTEGER) 成功傳回1,不成功傳回0 
//------------------------------------ 
// 作者: cwl 日期: 2001.12.15 
//====================================== 
Long Row 
String List 
string token[] 
String tag_1 
Integer StartPos = 1, EndPos, Top, i = 1 , index = 0 
//取出DW中所有的對象存入token[]中 
list = adw_1.Describe("datawindow. O B J E C Ts") 
EndPos = pos(list, '~t', StartPos) 
Do while ( EndPos > 0 ) 
token = Mid(list, StartPos, EndPos - StartPos) 
i ++ 
StartPos = EndPos + 1 
EndPos = pos(list, '~t', StartPos) 
LOOP 
token = Mid(list, StartPos) 
Top = UpperBound(token[]) 

//找出最後一列 
string ls_lastcol 
int li_lastpos=0,li_thispos 
For i = 1 to Top 
CHOOSE CASE UPPER(adw_1.Describe(token + '.type')) 
CASE 'COLUMN', 'COMPUTE' 
li_thispos = integer(adw_1.Describe(token + '.X')) 
if li_thispos>=li_lastpos then //這是目前最後一列 
li_lastpos=li_thispos 
ls_lastcol=token 
end if 
end choose 
NEXT 
//設定表頭長度 
string ls_change 
ls_change="800~tlong(describe('"+ls_lastcol+".x')) + long(describe('"+ls_lastcol +".width')) + 10" 
//messagebox('',ls_change) 
adw_1.modify('title.width="'+ls_change+'"') 

return 1

42、如何在資料窗中得到自動高的列的高度?
答:desceibe("evaluate('RowHeight()',3)") //獲得第三行的row的高度

42、如何使dw的列不可移動,不可調整列寬?
答:在datawindow的cilcked事件寫 

if row=0 then 
return 1 
end if

43.光标跳轉到資料視窗的某一行某一列
dw_1.scrolltorow(ll_row)
dw_1.setcolumn(ll_column)  
44 如何使光标指向每頁第一行?  
long ll_firstrowonpage=long(dw_1.describe("datawindow.firstrowonpage")) dw_1.scrolltorow(ll_firstrowonpage) dw_1.setrow(ll_firstrowonpage) 45. Grid的視窗如何使第一列固定不動?  
①選上data OBJECT的HSplitScroll屬性
②在constructor事件中:
dw_1.Object.DataWindow.HorizontalScrollSplit=integer(dw_1.describe("#1.width")) //第一列的寬度
③在scrollhorizontal事件中:
int i if pane = 1 then i = integer(this.OBJECT.datawindow.horizontalscrollposition2) if i < 1 or isnull(i) then return if scrollpos > 0 then this.OBJECT.datawindow.horizontalScrollPosition = 0 end if else i = integer(this.Object.DataWindow.HorizontalScrollSplit) if i < 1 or isnull(i) then return if i > scrollpos then this.OBJECT.datawindow.horizontalScrollPosition2 = i end if end if 46. 怎樣取子資料視窗的總列數 ll_column_count=integer(dwc.describe("datawindow.column.count")) //dwc為子視窗
47.在資料視窗過濾以後,計算列值如何才能一起改變? dw_1.setfilter(filter_condition) dw_1.filter() dw_1.groupcalc() 48.怎麼改變某一列的背景顔色?
dw_1.Modify("sno.background.mode=2" )
dw_1.Modify ( "sno.background.Color='255'" ) 49.在資料視窗中如何delete選中的多行? Long ll_rows , ll_row
ll_rows=DW_1.RowCount()
for ll_row = ll_rows to 1 step -1
if dw_1.isSelected(ll_row) then
dw_1.DeleteRow(ll_row)
end if
next 50.如何改變列的字型顔色,提醒使用者此列已做修改
  在列的Color屬性中,輸入如下表達式
IF (column_name < >column_name.Original, RGB(255, 0, 0), RGB(0, 0, 0))

51.資料視窗中限定某列不可編輯 用DataWindow的clicked事件中的方法也可以實作列的保護。若
某列不可更改,則可置r otect=0。即:
dw_1.modify("columnname.protect=0")
或dw_1.modify("#"+string(number)+".protect=0")
若要将該列改為可更改,則置protect=1,即:
dw_1.modify(:columnname.protect=1")
或dw_1.modify("#"+string(number)+".protect=1")
此方法不影響Tab鍵的移動,使用者可以随意拉動列,還可在應用過
程中自己決定哪一列可編輯,哪一列不可編輯。
52.怎樣去掉上圖中資料視窗中的黑影? this.Modify ("DataWindow.selected.mouse=no")
this.Modify ("DataWindow.Grid.ColumnMove = false") 53 實作逐行增加求和

使用計算列:CumulativeSum(field for all),即可達到逐漸遞增求和的功能

54 快速删除多行

方法是把要删除的行從主緩沖區中移到删除緩沖區中。例如,删除緩沖區中所有的行: dw_1.RowsMove(dw_1, 1, dw_1.RowCount, Primary!, dw_1, 1, Delete!)
58、在分組的header上加序号
答:建立計算域,expression:cumulativeSum( If (jlxm = jlxm[-1],0,1) for all)
59、為什麼varchar字段類型的列隻能儲存255個字元?
答:設定事務處理對象的dbparm屬性即可
示例:

SQLCA.dbParm = "DBTextLimit = '9999'"

60、點選grid類型資料視窗的header,自動排序。(圖檔自己做)
/*
*args: i_str_oldcol
*note:執行個體變量,紀錄上次點選的列
*/
string i_str_oldcol
string str_ O B J E C Tname, str_curcol, str_addpic
integer int_pic_x
str_ O B J E C Tname =string (dwo.name) //對象名稱
if row = 0 and this.describe(str_ O B J E C Tname+".band") = "header" and this.describe(str_ O B J E C Tname+".text") <> "!" then //是否點選列對象
str_curcol = left(str_ O B J E C Tname,len(str_ O B J E C Tname) - 2) //目前列對象名稱
if str_curcol <> i_str_oldcol then //點選的是不同列對象
this.modify("destroy p_sort") //不管有沒有位圖對象都删除
i_str_oldcol = str_curcol //儲存上次點選的列對象
//畫圖
int_pic_x = integer(this.describe(str_ O B J E C Tname+".x")) + (integer(this.describe(str_ O B J E C Tname+".width")) - 70)
str_addpic = 'create bitmap(band = foreground filename= "..\pic\up.bmp" x= "'+string(int_pic_x)+'" y= "24" height= "48" width= "48" 0" name= p_sort visible= "1")'
this.modify(str_addpic) //動态畫個圖
this.setsort(str_curcol + " A") //頭一次點選當然是升序了
this.sort()
else //目前列已經點過了
if this.describe("p_sort.filename") = "..\pic\up.bmp" then //上次是升序
this.modify("p_sort.filename = '..\pic\down.bmp'")
this.setsort(str_curcol + " D") //這次是降序
else
this.modify("p_sort.filename = '..\pic\up.bmp'")
this.setsort(str_curcol + " A")
end if
this.sort()
end if
end if

1、如何讓存儲檔案目錄的列,顯示圖檔?

答:選擇對應的column的display as picture屬性為true

2、如何複制grid類型的所選擇的行的資料到系統剪切闆?

答:string ls_selected

ls_selected=dw_1.Object.DataWindow.Selected.Data

clipbord(ls_selected)

4、如何設定的DW底色?

在DW的editsource中改變color的值

5、如何将Grid風格改成自由格式?

在DW的editsource中将processing=1的1改為0

6、要建立一個表A但風格和現有表格B風格一樣,怎麼将A表快速設定成表B風格?

複制B表C,在C表的DW中的editsource中将表名和字段名改成A表的,即可

7、如何實作gird風格的datawindow的多欄表頭?

答:添加 text到header帶區,并設定band屬性為foreground儲存,edit source 修改text的x和width屬性表達式如下:

x="100~t integer(describe('firstcol.x')" width="100~tinteger(describe('lastcol.x')) - integer(describe('firstcol.x')) +integer(describe('lastcol.width'))

8、如何過濾dddw編輯風格的顯示值為指定值的記錄?

答:dw_1.setfilter("lookupdisplay('column_name')='"+ls_display_value_your+"'")

dw_1.filter()

9、如何設定datawindow的某一列為空?

答:string ls_temp[]

setnull(ls_temp)

dw_1.object.columnname.primary.current=ls_temp

10、如何設定datawindow的單雙行不同顔色間隔?
答:在detail帶區的color屬性表達式中寫上if(mod (getrow(),2)=1 ,rgb(255,0,0),rgb(0,255,0)),如果是目前行以第三種顔色表示,表達式如下:if(getrow()=current(), rgb(255,0,0),if(mod(getrow(),2)=1 ,rgb(0,0,255),rgb(0,255,0)))

11、如何擷取指定名稱的datawindowobject?
答:DWObject ldwo_use,ldwo_abc ldwo_use = dw_1.Object ldwo_abc = ldwo_use.__get_attribute("t_1",FALSE)//t_1為datawindow中text對象的名稱

12、如何縮放datawindow的列印大小?
答:dw_1.object.datawindow.zoom=150 or dw_1.object.datawindow.zoom=75

13、如何在已過濾後的資料基礎上對datawindow進行過濾?
答:dw_1.setfilter(dw_1.describe("datawindow.table.filter")+your_join+your_new_filter)
dw_1.filter()

14、如何在datawindow中顯示動态時間?
答:建立一個計算域,表達式為string(datetime(today(),now()),'yyyy年mm月dd日 hh點mm分ss秒'),同時設定datawindow的屬性dw_1.Object.DataWindow.Timer_Interval=500

15、如何讓帶用title bar的datawindow控件的标題欄誠活動視窗的顔色?
答:外部函數定義:
funcation logn SetActiveWindow(long hwnd ) Library "user32.dll"
datawindow控件的clicked事件代碼:
setactivewindow(handle(this))

16、如何設定datawindow的目前行訓示圖示?
答:在datawindow中建立一個計算列,expression為'',并将該計算列移動為datawindow的第一個列,在datawindow控件的
rowfocuschanged事件中寫入代碼:
SetRowFocusIndicator(hand!)或setrowfucsindicator(p_1)//p_1為視窗上的picture控件名

17、如何通過代碼打開dddw?
答:定義外部函數引用聲明
SUBROUTINE keybd_event( int bVk, int bScan, int dwFlags, int dwExtraInfo) LIBRARY "user32.dll"
代碼如下: [constant integer VK_F4 = 115
dw_1.SetFocus()
dw_1.SetColumn( "dept_head_id" ) //設定目前dddw
keybd_event( VK_F4,0,0,0 ) // 按下F4鍵
keybd_event( VK_F4,0,2,0 ) // 釋放F4鍵

18、如何列印datawindow的内容到檔案中?
答: dw_1.object.datawindow.print.fileName ="c:\temp.prn"
dw_1.print()

19、如何設定dddw的初始值?
答:dw_1.object.columnname.Initial="your_initial_value"

20、如何隻顯示不同的資料?
答:dw_1.filter("isnull(columnname[-1]) and columnname<>columnname[-1]")
dw_1.filter()

21、如何讓帶有title bar的datawindow不可以移動?
答:在datawindow的自定義事件ue_nchittest(pbm_nchittest)中寫入如下代碼:
return 1

22、如何在N-UP顯示風格中建立基于第N欄中的列的計算列?
答:如column有兩列,number和price ,并顯示為兩欄,則第一欄的cost計算列的expression為number*price,第二欄的cost_1計算列的expression為number[1]*price[1]

23、如何清空ddlb或edit.codetable中項目?
答:dw_1.Object.columnname.Values=""

24、如何實作指定的column的字型旋轉90度?
答:dw_1.object.columnname.font.Escapement ="900"

25、如何擷取datawindow的sql代碼?
答: 可以通過以下四種方法擷取sql代碼:
string szselect
szselect=dw_1.describe("datawindow.table.select")
szselect=dw_1.describe("datawindow.table.sqlselect")
szselect=dw_1.describe("datawindow.table.select.attribute")
szselect=dw_1.getsqlselect()

27、如何擷取datawindow對象占有的虛拟存儲的容量?
答:使用datawindow.storage屬性
舉例:在datawindow控件的retrieverow事件中,寫如如下代碼:
long lstorage
lstorage=long(dw_1.object.datawindow.storage)
if lstorage>50000 then dbcancel()

28、如何連續在同一張紙列印兩個資料視窗?
答:dw_1.object.datawindow.print.filename="temp.prn"
dw_2.object.datawindow.print.filename="temp.prn"
dw_1.print()
dw_2.print()

29、如何設定datawindow分組後每個分組中的記錄号?
答:建立一個計算列,expression為 getrow() - first(getrow() for group 1)+1

30、如何實作在datawindow中隻有新增的行,才可以編輯?
答:在所有的column的protect屬性表達式中寫入以下表達式:
if(isrownew(),'0','1')

31、除了循環以外,有沒有更好的方法統計資料視窗中處于選中狀态的行數?
一般習慣于使用循環來統計資料視窗中處于選中狀态的行數,有沒有更好的方法?其實此問題在應用上用處不大,讨論一下,活躍一下思維還是有好處的。
方法一: long ll_Selected ll_Selected = long(dw_1.describe("evaluate('sum( if(IsSelected(), 1, 0) for all)',1)"))
方法二: long ll_Selected ll_Selected = long(dw_1.describe("evaluate('count(IsSelected() for all)',1)"))
方法三:upperbound(dw_1.Object.Data.Selected)

32、問:怎麼讓PB隻列印目前記錄,是用Free格式制作的資料視窗!
---------------------------------------------------------------
答:
DataStore ldt_temp
long ll_Row , ll_Rows
ll_Rows = dw_XX.Rowcount()
If ll_Rows = 0 Then GoTo the_end
If ll_Rows = 1 Then
dw_XX.Print()
GoTo the_end
End if
dw_XX.SetRedraw(False)
ldt_temp = Create DataStore
ldt_temp.DataObject = dw_XX.DataObject
ll_Row = dw_XX.GetRow()
dw_XX.RowsMove(1 , ll_Rows , Primary! , ldt_temp , 1 , Primary!)
ldt_temp.RowsMove(ll_Row , ll_Row , Primary! , dw_XX , 1 , Primary!)
dw_XX.Print()
dw_XX.RowsMove(1 , 1 , Primary! , ldt_temp , ll_Row , Primary!)
ldt_temp.RowsMove(1 , ll_Rows , Primary! , dw_XX , 1 , Primary!)
Destroy ldt_temp
dw_XX.SetRedraw(True)
the_end:
// 隻用将上述腳本拷入到列印部分即可,dw_XX為被列印的free型資料視窗,該方法可保證dw_XX中的資料在列印前後包括sort等屬性均不發生任何改變,但效率較低,不宜用在資料量太大的資料視窗中,當然,考慮到列印本身速度就比較慢,是以3000行資料是可以采用這種方法并讓使用者接受的。若在同一視窗上存在與dw_XX共享的grid資料視窗并且與dw_XX同時顯示,則需要與dw_one一起SetRedraw()

38、字段如何自動換行的同時且自動高度?
答:将資料視窗中相應列的auto horz scroll 為不選中,選中autosize height 将detail的autosize height選中。在資料視窗retrieve 後調用下面函數即可 uf_set_text(datawindow adw_content,string as_columns,boolean,ab_ignoreblank) /************************************************************* describe: 在資料視窗adw_content中,在as_columns中包含的列中插入空格 args: as_columns 要操作的多個列,列間用逗号隔開 *************************************************************/ if (not isvalid(adw_content)) or isnull(as_columns) or len(as_columns)<1 or isnull(ab_ignoreblank) then return -1 n_cst_string lnv_string string ls_column[] , ls_width ,as_source,as_replaced ,ls_temp int li_upperbound , li_width , li_column , li_fontWidth, li_counter long ll_rowcount , ll_row , ll_totalstep int li_yield lnv_string.of_parsetoarray(as_columns,',',ls_column) li_upperbound = upperbound(ls_column) ll_rowcount = adw_content.rowcount() if li_upperbound<1 or ll_rowcount<1 then return -1 openwithparm(w_waiting,this) ib_cancel = false iw_frame.enabled = false ll_totalstep = ll_rowcount * li_upperbound w_waiting.uf_register(ll_totalstep) for li_column = 1 to li_upperbound ls_width = adw_content.describe(ls_column[li_column]+".width") li_width = integer(ls_width) if ls_width='!' or ls_width='?' or li_width=0 then continue end if //ls_temp = adw_content.describe(ls_column[li_column]+".Font.property { = 'width' }") //messagebox(ls_column[li_column]+".Font.property { = 'width' }",ls_temp) //return 1 li_fontwidth = 27 li_counter = li_width / li_fontWidth for ll_row=1 to ll_rowcount if ib_cancel then iw_frame.enabled = true return 0 //pressed cancel button end if as_source = adw_content.getitemstring(ll_row,ls_column[li_column]) as_replaced = uf_insertstring(as_source,li_counter,' ',false) if as_replaced<>as_source then adw_content.setitem(ll_row,ls_column[li_column],as_replaced) end if w_waiting.uf_stepit() next next close(w_waiting) iw_frame.enabled = true return 1

39、如何使dw的列不可移動,不可調整列寬?
答:在datawindow的cilcked事件寫 if row=0 then return 1 end if

40.光标跳轉到資料視窗的某一行某一列
dw_1.scrolltorow(ll_row) dw_1.setcolumn(ll_column)

41 如何使光标指向每頁第一行?
long ll_firstrowonpage=long(dw_1.describe("datawindow.firstrowonpage"))
dw_1.scrolltorow(ll_firstrowonpage)
dw_1.setrow(ll_firstrowonpage)

42. Grid的視窗如何使第一列固定不動?
①選上data OBJECT的HSplitScroll屬性 ②在constructor事件中: dw_1.Object.DataWindow.HorizontalScrollSplit=integer(dw_1.describe("#1.width")) //第一列的寬度 ③在scrollhorizontal事件中: int i
if pane = 1 then
i = integer(this.OBJECT.datawindow.horizontalscrollposition2)
if i < 1 or isnull(i) then return
if scrollpos > 0 then
this.OBJECT.datawindow.horizontalScrollPosition = 0
end if
else
i = integer(this.Object.DataWindow.HorizontalScrollSplit)
if i < 1 or isnull(i) then return
if i > scrollpos then
this.OBJECT.datawindow.horizontalScrollPosition2 = i
end if
end if
把如下代碼放在某列的text color裡,可實作修改某行某列後,該列變為紅色,否則為白色(前景)
If(IsRowModified(), 255, 0) 

彈出式菜單
//m_module是菜單名
m_module m_newmenu
m_newmenu=create m_module
m_newmenu.popmenu(pointerX(),pointerY()) 

這段代碼不用API就可以取IP
Integer lifilenum
String lsbat , lsdat
String lstext,lsip[]
Long i , llfilename
llfilename = 0
Do While True
llfilename ++
lsbat = 'C:\' + String(llfilename) + '.BAT'
If FileExists(lsbat) Then Continue
// If DirectoryExists(lsbat) Then Continue
Exit
Loop
llfilename = 0
Do While True
llfilename ++
lsdat = 'C:\' + String(llfilename) + '.DAT'
If FileExists(lsdat) Then Continue
// If DirectoryExists(lsdat) Then Continue
Exit
Loop
lifilenum = FileOpen(lsbat,linemode!, Write!, lockwrite!, Replace!)
FileWrite(lifilenum,'ipconfig > ' + lsdat)
FileClose(lifilenum)
Run(lsbat,minimized!)
Do While True
Yield()
If FileExists(lsdat) Then Exit
Loop
Do While True
Yield()
lifilenum = FileOpen(lsdat,linemode!)
If lifilenum > 0 Then Exit
Loop
Do While True
Yield()
If FileRead(lifilenum, lstext) = -100 Then
Exit
Else
If Pos(lstext,'IP Address') > 0 Then
lsip[UpperBound(lsip) + 1] = Mid(lstext,Pos(lstext,':') + 1)
End If
End If
Loop
FileClose(lifilenum)
FileDelete(lsbat)
FileDelete(lsdat)
If UpperBound(lsip) = 0 Then
MessageBox('','沒有網卡或網絡連接配接未啟用!')
Else
For i = 1 To UpperBound(lsip)
MessageBox('IP:'+String(i),lsip)
Next
End If 
(
聲明win32 API函數: 
function int WSAStartup( uint UIVersionRequested, ref s_WSAData lpWSAData ) library "wsock32.dll" 
function int WSACleanup() library "wsock32.dll" 
function int WSAGetLastError ( ) library "wsock32.dll" 
function int gethostname ( ref string name, int namelen ) library "wsock32.dll" 
function string GetHost(string lpszhost, ref blob lpszaddress ) library "pbws32.dll" 
使用方法: 
s_wsadata l_WSAData 
string ls_HostName = space(128) 
string ls_IpAddress 
int li_version = 257 
blob{4} lb_hostaddress 
IF wsastartup ( li_version, l_WSAData ) = 0 THEN 
IF gethostname ( ls_HostName, len(ls_HostName) ) < 0 THEN 
messagebox("GetHostName",WSAGetLastError()) 
ELSE 
GetHost(ls_HostName, lb_HostAddress) 
ls_IpAddress = string(asc(string(blobmid(lb_HostAddress,1,1))),"000") + "." 
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,2,1))),"000") + "." 
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,3,1))),"000") + "." 
ls_IpAddress += string(asc(string(blobmid(lb_HostAddress,4,1))),"000") 
END IF 
WSACleanup() 
ELSE 
messagebox("GetHostName",WSAGetLastError()) 
END IF 
sle_1.text=ls_hostname 
sle_2.text=ls_ipaddress 
)


嵌入桌面
Function Ulong FindWindowA(string classname, String windowname) Library "user32.dll"

Function Long SetParent(Long childwin, Long parentwin) Library "user32.dll" 
long ll_handle
ll_handle=findwindowa(“Progman”, “Program Manager”)
setparent(handle("我的視窗"),ll_handle)

非複合報表中的嵌套報表不可使用getchild取得,也不可使用describe取得屬性和使用modify更改屬性,你可以調用PB未載入文檔的函數來擷取/更改屬性,請看示例,注意多層嵌套時使用循環擷取最終對象.
例:資料視窗控件dw_test包含嵌套報表dw_1,dw_1有欄位dept_name.
dwobject ldwo_parent,ldwo_obj
string ls_color
ldwo_parent = dw_1.object
ldwo_obj = ldwo_parent.__get_attribute("dw_1",false)
ldwo_obj = ldwo_obj.object
ldwo_obj = ldwo_obj.__get_attribute("dept_name",false)
ls_color = ldwo_obj.color//取顔色
ldwo_obj.__set_attribute("color",rgb(192,192,192))//更改顔色


EXCEL的内容導入資料視窗
string str_savename,named,s_grxh
int excelok,li_net
long li_count,i
oleobject excelserver
excelserver=create oleobject
excelok=excelserver.connecttonewobject("excel.application")
if excelok<>0 then
messagebox("資訊提示","連接配接excel失敗,請檢查計算機中是否安裝了excel!")
return -1
end if
li_net=getfileopenname("選擇檔案",str_savename,named,"xls","excel檔案(*.xls),*xls")
if li_net>0 then
if str_savename="" then 
messagebox("資訊提示","沒有指定導入檔案!")
return -1
else
dw_1.settransobject(sqlca)
dw_1.reset()
excelserver.workbooks.open(str_savename)
excelserver.activesheet.cells.copy
li_count=dw_1.importclipboard(2)
clipboard("")
excelserver.quit()
excelserver.disconnectobject()
cb_2.enabled=true
this.enabled=false
destroy excelserver
return 1
end if
end if

PB資料轉到EXCEL裡面不能求和 pb轉過去的都是字元型的 怎麼解決!! 
ole_object.Worksheets(1).Columns(1).NumberFormat = "@"這個是把一個列,變成字元,"#"是數字 

讓DW中的行單、雙行顯示不同顔色
if(currentrow()=getrow(),rgb(185,200,255),if(mod(getrow(),2)=1, rgb(255,255,255) , rgb(240,243,255))) 


滿足條件時該列字型顯示為紅色。
tab_1.tabpage_1.dw_1.Object.czr.Color = "0~tIf(string(zlzq,'yyyy-mm')<=string(today(),'yyyy-mm'),rgb(241,0,51),rgb(0,0,0))"

滿足條件時該列背景色為紅色
tab_1.tabpage_1.dw_1.modify("djh.background.mode=0")//
tab_1.tabpage_1.dw_1.object.djh.background.color = "0~tif ( string(zlzq,'yyyy-mm')<=string(today(),'yyyy-mm'), rgb(255,0,0), rgb(255,255,255))" 

按下Insert鍵時插入一行
//自定義一個PBM_DWNKEY的事件在事件裡寫(可能有别的簡單的方法)
if keydown(keycontrol!) then
if keydown(KeyInsert!) then
//插入一行

dwname.insertrow(0)
end if
end if


當某列獲得焦點是,光标移動到最後
方法一:
//獲得焦點時,按下END鍵
public Subroutine keybd_event(int bVk,int bScan,ulong dwFlags,ulong dwExtraInfo) LIBRARY "user32.dll" 
if dwo.name = "sqr_gzdw" then
keybd_event(35,0,0,0)
end if
方法二:
           
this.setcolumn("po_gzdw") //讓這列先獲得焦點
this.selecttext( len(data) + 1,0 ) //再從最後選種0個字元