문제

I have a datagrid, its datasource is a dataview. There is a textbox with which users can type in filter text. I want to make the filter to be case insensitive. say, the typed text is "Tg"

I tried this

Mydataview.RowFilter = "UPPER(COL) LIKE '%TG%'"

but this gives me an invalidoperation exception

then I changed it to

Mydataview.RowFilter = "COL LIKE '%tg%' or COL LIKE '%TG%'"

This works but it does not cover all cases. E.g. If a row is "Tg", it will be filtered out which is not desirable. What I want, when users type "Tg", it will match any data with tg, Tg, TG, tG, all the combination

thanks

도움이 되었습니까?

해결책

RowFilter obeys dataset CaseSensitive value

So do this in your Form_Load method:

CaseSensitive is set to False by default

mydataset.CaseSensitive = false

Proof of concept:

enter image description here

다른 팁

select the name twice with one of them being upper(name) as finder and then use that column (non visable) to filter your rows

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top