datagrid的頁內查找函數[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 landlordh 的 blog

在自己寃著開發的過程中,寫了一些可重用的代碼,願與大家分享一下.
因為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

本文关键:datagrid的頁內查找函數
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top