Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid data displayed based on radio button 1

Status
Not open for further replies.

surfside1

Programmer
Feb 12, 2006
209
US
I'm new to VB.NET Basic Edition. I've done this in Access but not sure how to begin in VB. I have a datagrid tied to a table. I want to use radio buttons to display the records I want in the grid, such as "all", "sold", etc which is identified by Status_Code in table.

In Access I created queries for each option, then on the AfterUpdate of the option group, I did a Select Case like:
Private Sub option_View_Listings_AfterUpdate()
Dim qwyName As String
Dim subformName As String
Select Case option_View_Listings
Case 1
qwyName = "qwy_Listings_All"
Case 2
qwyName = "qwy_Listings_Sold"
End Select
Then:
Me.subform_Listings.Form.RecordSource = qwyName

I want to put code behind an event when the button is clicked:

Private Sub radioAll_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioAll.CheckedChanged

End Sub

How do I do this? Thanks for your input!
 
A datagrid(view?) is normally bound to a table through a datagrid(view?)bindingsource. The bindingsource object has a Filter property you use in this case. So when the user clicks the all radiobutton:

Code:
    Me.DataGridViewBindingSource.Filter = String.empty

When they click the Sold radiobutton:

Code:
    Me.DataGridViewBindingSource.Filter = "Status = 'Sold'"

That should point you in the right direction and let us know if you need some more specific direction.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Great, thanks, haven't used filters yet but it seems straight forward. We'll see....
Thanks again.
 
I coded the statement when the sold radio button was clicked:

Me.DataGridViewTextBoxStatus. and then I thought there would be a "filter" selection that would be listed to type after the .(period) but there wasn't. The DataGridViewTextBoxStatus is the name of the bound column. Am I on the right track? Thanks!
 
Almost....You need to be referencing the name of the BindingSource object.

If you used the drag and drop method to place your table/view onto the form, two objects should have been created for you...a table adapter and a bindingsource adapter. This show up in a small window on the bottom of your designer window.

If you did not use the drag and drop and add the datagrid yourself, you will probably want to look at working with an adapter and binding source object.

The filter I was referring to is part of the bidningsource object.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Got it now I understand!

Maybe you can help me out with my post thread796-1401226

I am trying to open a form that will display the data for the record that is clicked in the datagrid. That will allow them to go directly to the detail information for that record. Not sure how to set the where clause for the ID when opening the form using the ShowDialog.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top