代码我正在使用
(DataGridViewAllMusic.DataSource as DataTable).DefaultView.RowFilter =
string.Format("Title LIKE '%{0}%' or Artist LIKE '%{1}%' or Album LIKE '%{2}%' or
Comments LIKE '%{3}%' ",TextboxSearch.Text, TextboxSearch.Text, TextboxSearch.Text,
TextboxSearch.Text);
工作输出:
假设datagridview显示歌曲信息为(左侧的songtitle和右侧的艺术家)
title & 艺术家
温柔的生活& 三个度
和i Type life 在textboxsearch中datagridView将显示歌曲详细信息,因为word life 在datatable列中找到了 strong>
现在,如果我搜索度,则在DataTable列中再次找到度 Artist ,因此DataGridView将显示相同的结果
所需的过滤器:
现在我还希望以艺术家和歌曲标题的方式搜索这首歌。
这样
三度温柔的寿命如果我在TextBoxSearch中搜索此信息,那么DataGridView也应显示与在单独搜索标题或艺术家时显示的结果相同的结果
Code i am using
(DataGridViewAllMusic.DataSource as DataTable).DefaultView.RowFilter =
string.Format("Title LIKE '%{0}%' or Artist LIKE '%{1}%' or Album LIKE '%{2}%' or
Comments LIKE '%{3}%' ",TextboxSearch.Text, TextboxSearch.Text, TextboxSearch.Text,
TextboxSearch.Text);
Working output:
suppose datagridview showing song information as (SongTitle on left and Artist on right)
Title & Artist
A Tender Life & Three Degrees
and i type Life in TextboxSearch the datagridview will show the song detail since word Life is found in DataTable column Title
Now if i search Degree, again Degree is found in DataTable column Artist so the datagridview will show the same result
Desired filter:
Now i also want to search the song in a way like the artist and song title together.
such that
Three Degrees A Tender Life if i search this in TextboxSearch, the datagridview should also display the same result as displaying when searching the title or artist separately
发布评论
评论(1)
特别感谢 @null博士。我找到了他的VB.NET代码,并在C#中使用。它效果很好!
vb.net博士
A special thanks to @dr.null . I found his vb.net code and used in c#. It works great!
Vb.net by dr.null