Where is numbers 1, 2 & 3 Tricks? We can simply treat #1 as the More Objects inside a Cell blog, #2 as the Various Images II blog and #3 as the Transparent Grid blog.
I decided to start showing some more tricks I do on my side using grids which I deem will be useful for others as well. This is about making the search result clearer or more visible by highlighting the cell contents where a near match can be found. If not, it is very tiring for the user's eyes to trace where exactly those near matches are.
Actually, this entry is partly because of recent exchanges of ideas about the tricks and method in searching. What I wanted to show here is when you have several columns to look at and if the value in the search box can come from any of those columns, how can we easily distinguish where the near matches are? This trick aids visually the user just about that. Here is a sample code for this:
Local oForm
oForm=Newobject("Form1")
oForm.Show
Read Events
Return
Define Class Form1 As Form
Height = 390
Width = 770
AutoCenter = .T.
Caption = 'Clearer Search Results'
ShowTips = .T.
_cSearch = ''
Add Object grid1 As Grid With ;
GridLines = 0, ;
Height = 328, ;
Left = 10, ;
Top = 50, ;
Width = 750,;
GridLines = 3,;
DeleteMark = .F.,;
GridLineColor = Rgb(192,192,192),;
FontName = 'Tahoma',;
FontSize = 8
Add Object label1 As Label With ;
top = 15,;
left = 10,;
caption = 'Search',;
Backstyle = 0
Add Object Text1 As TextBox With ;
top = 10,;
left = 55,;
Height = 23,;
Width = 300,;
value = '',;
ToolTipText = 'Start typing to search matching records,'+;
' Double-click to clear search'
Procedure Load
Set Talk Off
Set Safety Off
Close Databases All
Select company,contact,Title From (Home(2)+;
"data\customer") Where .F. Into Cursor junk1 Readwrite
Endproc
Procedure grid1.Init
With This
.RecordSourceType = 6
.RecordSource = 'junk1'
.Column1.DynamicForeColor = ;
'IIF(thisform._cSearch $ UPPER(company),RGB(255,128,0),RGB(0,0,0))'
.Column2.DynamicForeColor = ;
'IIF(thisform._cSearch $ UPPER(contact),RGB(255,128,0),RGB(0,0,0))'
.Column3.DynamicForeColor = ;
'IIF(thisform._cSearch $ UPPER(title),RGB(255,128,0),RGB(0,0,0))'
.Column1.DynamicFontBold = ;
'IIF(thisform._cSearch $ UPPER(company),.T.,.F.)'
.Column2.DynamicFontBold = ;
'IIF(thisform._cSearch $ UPPER(contact),.T.,.F.)'
.Column3.DynamicFontBold = ;
'IIF(thisform._cSearch $ UPPER(title),.T.,.F.)'
Endwith
Endproc
Procedure Text1.DblClick
This.Value = ''
Zap In junk1
Thisform.grid1.Refresh
Endproc
Procedure Text1.InteractiveChange
Local lcSearch
lcSearch = Upper(Alltrim(This.Value))
Thisform._cSearch = m.lcSearch
Select company, contact, Title From Home(2)+"data\customer" ;
Where Upper(cust_id+company+contact+Title);
LIKE '%'+m.lcSearch+'%' Into Cursor junk2 NOFILTER
Select junk1
Zap In junk1
Append From Dbf('Junk2')
Go Top
Thisform.grid1.Refresh
Endproc
Procedure Destroy
Clear Events
Endproc
Enddefine
The tricks employed here is via using DynamicForeColor and DynamicFontBold properties of a column. Another thing you have to notice here is my use of a form property because local variables go out of scope.
Well, those are just 3 simple things to look for. Now go employ this trick on your end.
Cheers!
Tidak ada komentar:
Posting Komentar