-
Jan 4th, 2018, 02:06 PM
#1
Thread Starter
New Member
DataGridView Data Source Question
i have a form built on a poker timer to select one of three data tables in an access database based on a radio button event
how do i tell the radio buttons to load the requisite table based on the radio button clicked?
tables are
daily
sunday
special
the base load is the daily
-
Jan 4th, 2018, 03:25 PM
#2
Re: DataGridView Data Source Question
Can you show your code that is loading the data.
Generally speaking you would change youre connection string conditionally as per the radio button value
-
Jan 4th, 2018, 04:35 PM
#3
Re: DataGridView Data Source Question
Generally speaking you would change youre connection string conditionally as per the radio button value
No you wouldn't change the connection string, it connects to the database file not individual tables. You would change the SQL command the retrieves the data.
You could do this in the Radio Button "CheckedChanged" event.
-
Jan 4th, 2018, 04:39 PM
#4
Re: DataGridView Data Source Question
Originally Posted by wes4dbt
No you wouldn't change the connection string, it connects to the database file not individual tables. You would change the SQL command the retrieves the data.
You could do this in the Radio Button "CheckedChanged" event.
That's what i meant actually. The commandtext
-
Jan 4th, 2018, 05:09 PM
#5
Thread Starter
New Member
Re: DataGridView Data Source Question
the base load is done through the properties setting on the datagridview. i was wondering if there was a means to adjust that instead of the connection string use
-
Jan 4th, 2018, 05:15 PM
#6
Re: DataGridView Data Source Question
I've already said where to make the datagridview datasource change, are you asking how to change the dgv datasource? If so, then you need to provide more information about the datasource and post your current code. It will be a lot easier to help you if you provide a Full and Clear explanation.
-
Jan 4th, 2018, 05:22 PM
#7
Thread Starter
New Member
Re: DataGridView Data Source Question
yes wes that is exactly what i am asking. the overall dataset is comprised of three tables in a connected resource database. in the properties view of the dgv i have the datasource set as DailyBindingSource in reference to the daily table. how would i programatically tell that property to adjust to the sundaybindingsource or specialbindingsource as needed based on a radio button checked on an alternate form. code as waiting is as follows
Private Sub RBDaily_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RBDaily.Click, RBSunday.Click, RBSpecial.Click
Dim rad As RadioButton = CType(sender, RadioButton)
Select Case rad.Name
Case RBDaily.Name
Form1.DataGridView1.DataSource =
Case RBSunday.Name
Form1.DataGridView1.DataSource =
Case RBSpecial.Name
Form1.DataGridView1.DataSource =
End Select
End Sub
-
Jan 4th, 2018, 05:39 PM
#8
Re: DataGridView Data Source Question
Well that's a start, so your saying the Radio buttons and the Datagridview are on different forms?
Which form is this code on,
Code:
Private Sub RBDaily_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RBDaily.Click, RBSunday.Click, RBSpecial.Click
Dim rad As RadioButton = CType(sender, RadioButton)
Select Case rad.Name
Case RBDaily.Name
Form1.DataGridView1.DataSource =
Case RBSunday.Name
Form1.DataGridView1.DataSource =
Case RBSpecial.Name
Form1.DataGridView1.DataSource =
End Select
End Sub
Are all the bindingsources in the same form as the dgv?
I still think you should be using the Radiobutton CheckedChanged event, like
Code:
Private Sub RBSunday_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged
If RBSunday.Checked Then
Form1.DataGridView1.DataSource = "yourdatasource"
End If
End Sub
-
Jan 4th, 2018, 05:48 PM
#9
Thread Starter
New Member
Re: DataGridView Data Source Question
that code is on formdataset
all binding sources are on form1 with the dgv
my question is more how do i reference the datasource to complete the line?
-
Jan 4th, 2018, 05:57 PM
#10
Re: DataGridView Data Source Question
Code:
Private Sub RBSunday_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged
If RBSunday.Checked Then
Form1.DataGridView1.DataSource = Form1.sundaybindingsource
End If
End Sub
That would be my guess but I can't be positive because I never use Default Form Instances like your doing. I don't like coding like that.
-
Jan 4th, 2018, 06:00 PM
#11
Thread Starter
New Member
Re: DataGridView Data Source Question
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|