国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

datagrid的頁內查找函數

2024-07-21 02:23:30
字體:
來源:轉載
供稿:網友
在自己學著開發的過程中,寫了一些可重用的代碼,願與大家分享一下.
因為datagrid沒有像delphi中的網格的網格內數據的查找功能,于是自己動手寫了一個:




--------------------------------------------------------------------------------
'
public function findto(byval mdatagrid as datagrid, byval nowindex as integer, byval maxindex as integer, byval caps as boolean, byval updown as boolean, byval mfieldname as integer, byval mfieldvalue as string) as integer

dim rowindex as integer = -1
dim regstring as string
regstring = mfieldvalue.replace("/", "//")
dim dgrow as integer
try
dim rx as system.text.regularexpressions.regex
if caps then
rx = new system.text.regularexpressions.regex(regstring, system.text.regularexpressions.regexoptions.ignorecase)
else
rx = new system.text.regularexpressions.regex(regstring)
end if
if updown then
for dgrow = nowindex - 1 to 0 step -1
if rx.ismatch(mdatagrid.item(dgrow, mfieldname).tostring) then
rowindex = dgrow
if rowindex <= nowindex then
mdatagrid.currentrowindex = rowindex
else
rowindex = -1
end if
exit for
end if
next
else
for dgrow = nowindex + 1 to maxindex
if rx.ismatch(mdatagrid.item(dgrow, mfieldname).tostring) then
rowindex = dgrow
if rowindex >= nowindex then
mdatagrid.currentrowindex = rowindex
else
rowindex = -1
end if
exit for
end if
next
end if
catch ex as exception
msgbox(ex.tostring)
end try
return rowindex

end function

'使用時
dim findindex as integer '找到的行
dim currow as integer
dim curcol as integer
curcol = sfieldname.selectedindex
if curcol = 0 then exit sub
currow = datagrid1.currentrowindex '
datagrid1.unselect(currow)
'功能說明: (選中該行)
'findto(網格的名稱,當前行號,數據記錄數,區分大小寫,向上or向下查找方向,列號,查詢值)
findindex = findto(datagrid1, currow, ds_rec.tables("rec").rows.count - 1, cap, searup, curcol, sfieldvalue.text.tostring)
if findindex <> -1 then
datagrid1.select(findindex)
else
msgbox("沒有找到匹配的項目!", msgboxstyle.information, "查找結果")
datagrid1.currentrowindex = currow
datagrid1.select(currow)
end if




發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 墨玉县| 宜城市| 进贤县| 阜城县| 罗江县| 象州县| 山东省| 阿瓦提县| 古交市| 乌兰浩特市| 岑巩县| 樟树市| 新源县| 本溪市| 观塘区| 如东县| 辉南县| 鄂温| 沐川县| 大余县| 集贤县| 万全县| 嘉禾县| 隆林| 石门县| 仲巴县| 城步| 辽阳市| 呼图壁县| 噶尔县| 孟州市| 翁牛特旗| 金秀| 横山县| 重庆市| 富阳市| 团风县| 广南县| 巴青县| 柳江县| 茂名市|