|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
filter rows in a bound datagridVB.Net 2005
I have a bound datagrid with a list of names. I want to add a button that will filter the names so that only the names that start with "H" will display. How would I do that? Thanks for help. I would:
1) place the list of names in a DataTable 2) create a DataView based on the DataTable 3) bind the grid to the DataView Then, when the user clicks the button, you can simpley change the Filter property of the DataView and your grid will change accordingly. I have my grid bound to an Access database via the datawizard in vb.net
2005. I don't think I can bind to a view? Can I? Show quoteHide quote "Virgil" <vschle***@trilliumteam.com> wrote in message news:1141322693.971155.8630@t39g2000cwt.googlegroups.com... >I would: > 1) place the list of names in a DataTable > 2) create a DataView based on the DataTable > 3) bind the grid to the DataView > > Then, when the user clicks the button, you can simpley change the > Filter property of the DataView and your grid will change accordingly. > Hi phonl,
Yes, you can still bind to a view. You need to drag and drop a DataView from the toolbox. (If it is not in the toolbox, right click in the toolbox and add it using Choose Items.) Then you have to set the DataView.Table property to the DataTable that contains data, and set the grid data source to the DataView. HTH. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." Thank you Kevin and Devlei.
I like the DataView. I would like to know more about the "DataView.RowFilter". It seems to be limited so I can't do "AND", "OR" etc to do more complex filters. Is correct; or am I not using the proper syntax? DataView1.RowFilter = "REQUEST_BY = 'Pete' AND OBJECTIVES = '7A'" or DataView1.RowFilter = "REQUEST_BY = 'Pete' AND OBJECTIVES LIKE '7%'" Show quoteHide quote "Kevin Yu [MSFT]" <v-k***@online.microsoft.com> wrote in message news:mRoWf8nPGHA.5536@TK2MSFTNGXA03.phx.gbl... > Hi phonl, > > Yes, you can still bind to a view. You need to drag and drop a DataView > from the toolbox. (If it is not in the toolbox, right click in the toolbox > and add it using Choose Items.) > > Then you have to set the DataView.Table property to the DataTable that > contains data, and set the grid data source to the DataView. HTH. > > Kevin Yu > ======= > "This posting is provided "AS IS" with no warranties, and confers no > rights." > Hi Phonl,
We can use AND, OR operators in the RowFilter. Actually, the RowFilter property is using the same syntax as the DataColumn.Expression property. You can check the following link for more information on the syntax of it. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/ frlrfsystemdatadatacolumnclassexpressiontopic.asp Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." Fill a Dataset with your Access data, then add a DataView object, and
set its Table property to the "Dataset.Table". Then use the DataView.RowFilter property to filter like, "Name = 'Harry'". The Datagrid.DataSource property must be set to the DataView. Hope that helps.
delete row from dataview
Problem: Unwanted Paper feed after printing. File test problems with URL value in webbrowser app Delimiter question Unable to recognize stored procedure param Modules in 2005 fonts at runtime Property 'FlowBreak' accessible only at design mode ? Intermittent VS.Net Pauses during VB.NET code writing |
|||||||||||||||||||||||