Link to home
Start Free TrialLog in
Avatar of rolltide0
rolltide0

asked on

Need help with DataGridView object

I need a little assistance with DataGrids. I can bind the grid and have it show data no problem, but the table it is bound to I  don't want to show all the data, just data based on the  current order number (which is a column in the table). Can anyone assist me on this issue?
ASKER CERTIFIED SOLUTION
Avatar of vbturbo
vbturbo
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JonMny
JonMny

    Dim s As New BindingSource()
       s.DataSource = lst
        Me.DataGridView1.DataSource = s
        s.Filter = "Ordernumber = 2"
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
VBRocks has provided you with a very good approach when handling a great amount of rows.
i agree with him.

Though you should let the database do what it is best to , handle perfomance heavy jobs.
This is what it is designed for among others.

My point of view is that when having a fair amount of rows and perhaps long order numbers
maybee 5-15 digits or even longer then there is a big advantice in filtering when typing.

so whatever choise you make , i think it comes down to user interaction,taste and performance < 1000 rows.

vbturbo

 
Avatar of rolltide0

ASKER

All three of you all gave great suggestions. Due to finals I haven't had the opportunity to try any of them. Vbturbo, can you explain your solution with a little more detail? The convert method is something I am not familiar. So if you have time, a line by line explanation would be very helpful.
Hi

When filtering on column data which is (type of) integer then you can only use the "=" equal operator
as suggested by VBRocks.
:Display's only a match in the filter when it exacly match's your filter argument
 

By using the convert tostring method on the column (integer) you can now apply the LIKE operator on the
column filter.
:Display's all records which match each time you type a argument in your txtbox.

Try have a look on table column expressions
http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

vbturbo