How to solve problem with datagrid and tabcontrol

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Good day,

I created a tabcontrol that has more than two tabpages, in each of the tabpages, i have a datagrid except the first page.
I have populated the datagrid successfully. The problem is when i click to view the 2nd tab page, the content of the datagrid will display well but on the 3rd tabpage, the content of the datagrid will not be visible (the text is white in color), that is the datagrid on the 3rd tabpage will be populated with data but the content is white in color thereby its kinda invisible.

here is my code:

tab click event:

Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged


If TabControl1.SelectedIndex = 5 Then

load symptoms
loadSymptomsCmb()

load patient diagnosis history
loadDiagnosisHistory(mqhModule.treatPatID)


show doc name
txtDoc.Text = mqhModule.docName

ElseIf TabControl1.SelectedIndex = 6 Then


load prescription history
loadprescription(mqhModule.treatPatID)

load drugs
loadDrugsCmb()

show doc name
txtDrugsBy.Text = mqhModule.docName

End If

End Sub[/code]


code to populate datagrid:

Private Sub loadprescription(ByRef patID As String)



Try
retrieve patient info
retrieve patient info

open database
conMod.openDB()


get first student name list from database

Dim StrSQL As New SqlDataAdapter("SELECT drugs,medicine,dura,dosage,freq,drugInstruction " & _
"presTime,presDate,prescribeby " & _
" FROM patientprescription WHERE patientID=" & patID & " ", conMod.Con)

Dim DR As New DataSet

StrSQL.Fill(DR)
StrSQL.Dispose()

Dim usertable As DataTable = DR.Tables(0)




datasource of the datagrid
DGridPres.DataSource = usertable



change the data grid column name
DGridPres.Columns(0).HeaderText = "Medication"
DGridPres.Columns(1).HeaderText = "Drug"
DGridPres.Columns(2).HeaderText = "Duration"
DGridPres.Columns(3).HeaderText = "Dosage"
DGridPres.Columns(4).HeaderText = "Frquency"
DGridPres.Columns(5).HeaderText = "Instruction"
DGridPres.Columns(6).HeaderText = "Time"
DGridPres.Columns(7).HeaderText = "Date"
DGridPres.Columns(8).HeaderText = "Prescribed-By"



close database
conMod.closeDB()

catch exception
Catch ex As Exception

dsplay message
Dim mymsg As New myMsgbox

With mymsg
.txtError.Text = "Error! Could not retrieve Patient prescription Information."
End With

End Try


End Sub

View the full article
 
Back
Top