如何解决datagrid和tabcontrol的问题

如何解决datagrid和tabcontrol的问题

本文介绍了如何解决datagrid和tabcontrol的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天,



我创建了一个tabcontrol,它有两个以上的标签页,在每个标签页中,我有一个数据网格,除了第一页。

我已经成功填充了数据网格。问题是,当我点击查看第二个标签页时,数据网格的内容将显示良好,但在第三个标签页上,数据网格的内容将不可见(文本为白色),即数据网格上第三个标签页将填充数据,但内容为白色,因此它有点不可见。



这是我的代码:



标签点击事件:



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 it''s 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 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 

推荐答案



这篇关于如何解决datagrid和tabcontrol的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 03:56