Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

.net Panel retreving data after it is added to panel

Posted on 2012-09-18
8
Medium Priority
?
303 Views
Last Modified: 2012-09-19
i have 10 rows with 4 data items on each level
a  b c d
e f g h
....
what i find hard is that to get the data back to store it in a table
i have to do this
panel.controls.item(0) to get first items in row one  gives me a
panel.controls.item(1) to get second item in row one gives me b
panel.controls.item(2) to get 3rd item in row one gives me c
panel.controls.item(3) to get  4th item in row one gives me d
then to get the data in row 2
its
panel.controls.item(5) to get second item in row 2 gives me f
panel.controls.item(6) to get 3rd item in row 2 gives me g


But lets say i only want the data from item(1) and item(2)
so its really 1,2    row 1     (b,c)
                    4.5, for  row 2   (f,g)
     so on
i find i have to do a lot of stuff to get them
what are the ways to get the data i need

thanks
0
Comment
Question by:john M
  • 5
  • 3
8 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38411185
Can you elaborate a bit more? Show a screenshot?
0
 
LVL 3

Author Comment

by:john M
ID: 38411227
well its just a panel
'code to build
    Private Sub GetMissedExamsRecords()
        'xxx2


        'set the y point variable to 4
        TheYMe = 4
        '  Dim FinRecID As Integer = CInt(Me.fFinRecID.Text)

        ' Dim FinRecID As Integer = CInt(IIf(Me.fFinRecID.Text = "", 0, fFinRecID.Text))
        '  Dim OrderID As Integer = CInt(fOrderID.Text)
        '  MsgBox(Me.fOrderID.Text)

        MissExamsRecExit = False
        Try

            'start the data readerLoadF
            'MerchandiseItemsDataReader = LoadMerchandiseItemRecords(OrderID)
            'Dim MissedExamsDataReader As SqlDataReader = Nothing
            'Dim startdate As String
            'Dim enddate As String
            startdate = f1StartDate.Text
            enddate = f1EndDate.Text
            MissedExamsDataReader = rpReportBuilder.rp_ReportBuilder.GetMissedExams(f1StartDate.Text, f1EndDate.Text)

            MissedExamsI = 0

            If MissedExamsDataReader.Read Then 'reading first record already
                MissExamsRecExit = True
                PopulateFormMissedExamDetail() ' populate first record
                While MissedExamsDataReader.Read
                    'increase the location Y values and form height for the next row
                    TheYMe = TheYMe + 23
                    PopulateFormMissedExamDetail() ' populating the rest of the records
                End While
            Else
                'there's no finance datail Item records yet. do nothing
            End If



        Catch ex As Exception
            MessageBox.Show(ex.Message)

        Finally
            ' close the datareader in case it's still open
            If Not (MissedExamsDataReader Is Nothing) Then
                MissedExamsDataReader.Close()
            End If
        End Try

    End Sub



    Private Sub PopulateFormMissedExamDetail()
        'jpmmerch
        Try
            ' Set the X location point for the temporary controls
            fullname_X = 2 'Feecode_X = 1
            ExamType_X = 155
            Examid_X = 225 'chg from 72 'changed the position from 188 to 208 josem
            chk_X = 300
            payfor_x = 145
            Editfd_X = 230     'changed the position from 231 to 271 josm
            Linkfd_X = 257   'changed the position from 268 to 308 josem
            Deletefd_X = 284   'changed the position from 268 to 308 josem
            FinDetailPrim_X = 270
            FinDetailConcurrencyID_X = 300
            'Examid_X, ExamType_X,fullname_X,


            ' increase FinDetailI value plus 1
            ' the FinDetailI value is used to name the record fields
            '  AND as a tag id to highlight and retrive the selected record values
            'FinDetailI = FinDetailI + 1
            MissedExamsI = MissedExamsI + 1

            ' This inserts each of the retrieved record fields into dynamically created textboxes.

            'Dynamically add the Product Name textbox to the form and set its properties.
            txtfd_ = New Windows.Forms.TextBox
            With txtfd_
                .Name = "txtfd_Fullname" & MissedExamsI
                .Location = New System.Drawing.Point(fullname_X, TheYMe)
                .Size = New System.Drawing.Size(150, 20) 'Changed the size for 180 jose m
                'reg .BackColor = Color.FromArgb(255, 255, 255)
                .BackColor = Color.FromArgb(221, 231, 238) 'blue
                'org.BorderStyle = BorderStyle.FixedSingle
                .BorderStyle = BorderStyle.None
                .Tag = MissedExamsI
                If MissedExamsDataReader.IsDBNull(1) = True Then txtfd_.Text = Nothing _
               Else txtfd_.Text = MissedExamsDataReader.Item("FullName")
                .Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
                .ForeColor = System.Drawing.Color.Black
                .MaxLength = 50
            End With
            ''Add it to the form
            Me.ExamsPanel.Controls.Add(txtfd_)
            ''set it to be read only
            'Me.txtfd_.Enabled = False

            Me.txtfd_.ReadOnly = True

            ''Dynamically add the Quantity textbox to the form and set its properties.
            txtfd_ = New Windows.Forms.TextBox
            With txtfd_
                .Name = "txtfd_ExamType" & MissedExamsI
                .Location = New System.Drawing.Point(ExamType_X, TheYMe)
                .Size = New System.Drawing.Size(60, 20)
                '    ' .BackColor = Color.FromArgb(255, 255, 255)
                '    ' .BackColor = System.Drawing.Color.White
                .BackColor = Color.FromArgb(221, 231, 238) 'blue
                '    '.BorderStyle = BorderStyle.FixedSingle
                .BorderStyle = BorderStyle.None
                .Tag = MissedExamsI
                If MissedExamsDataReader.IsDBNull(3) = True Then txtfd_.Text = Nothing _
                Else txtfd_.Text = MissedExamsDataReader.Item("ExamType")

                .Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
                .ForeColor = System.Drawing.Color.Black
                .MaxLength = 10
                '    AddHandler txtfd_.KeyPress, AddressOf fcodeamount_KeyPress
            End With
            ''Add it to the form
            Me.ExamsPanel.Controls.Add(txtfd_)
            ''set it to be read only
            ''Me.txtfd_.Enabled = False
            Me.txtfd_.ReadOnly = True



            ''Dynamically add the Quantity textbox to the form and set its properties.
            txtfd_ = New Windows.Forms.TextBox
            With txtfd_
                .Name = "txtfd_ExamId" & MissedExamsI
                .Location = New System.Drawing.Point(Examid_X, TheYMe)
                .Size = New System.Drawing.Size(70, 20)
                '    ' .BackColor = Color.FromArgb(255, 255, 255)
                '    ' .BackColor = System.Drawing.Color.White
                .BackColor = Color.FromArgb(221, 231, 238) 'blue
                '    '.BorderStyle = BorderStyle.FixedSingle
                .BorderStyle = BorderStyle.None
                .Tag = MissedExamsI
                If MissedExamsDataReader.IsDBNull(2) = True Then txtfd_.Text = Nothing _
                Else txtfd_.Text = MissedExamsDataReader.Item("ExamId")

                .Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
                .ForeColor = System.Drawing.Color.Black
                .MaxLength = 10
                '    AddHandler txtfd_.KeyPress, AddressOf fcodeamount_KeyPress
            End With
            ''Add it to the form
            Me.ExamsPanel.Controls.Add(txtfd_)
            ''set it to be read only
            ''Me.txtfd_.Enabled = False
            Me.txtfd_.ReadOnly = True



            'Dynamically add the Checkbox to the form and set its properties.
            chk_ = New Windows.Forms.CheckBox
            With chk_
                .Location = New System.Drawing.Point(chk_X, TheYMe)
                .Name = "txt_checkbox" & MissedExamsI
                .Size = New System.Drawing.Size(20, 18)
                .BackColor = Color.FromArgb(255, 255, 255)
                .Tag = MissedExamsI
                .Enabled = True
                chk_.Checked = False
                .AutoCheck = False
                AddHandler chk_.Click, AddressOf checkboxbtn_click
                'End With
            End With
            'Add it to the form
            Me.ExamsPanel.Controls.Add(chk_)


        Catch ex As Exception
            '  Something went terribly wrong.  Warn user.
            MessageBox.Show("An Unexpected Error Occurred during the Finance Detail Item Listinng process. ", _
           "Finance Detail Item Records", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End Try
    End Sub

so as i said you end up with
in panelname.controls.item(0_

panel look like this

start date --/--/-- end date ---/--/--   put in date
 
get exams  click button
displays  ---
name              number           type              checkbox
john smith    1234546           hhh                    |  |




as i said above you end up with all the value in a table
panelname.controls.item(index)
but as i said the type field ends up in index level   2,6,10,14 ever 4th one from 2
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38412840
Can you not use a control like a DataGridView?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:john M
ID: 38413603
Thanks -
but not for this project - maybe in the futhur i will
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 38414192
If you are using a loop to get these, you can use the Step keyword

For i As Integer = 2 to 14 Step 4
     txt = panel1.Controls(i)
Next
0
 
LVL 3

Author Comment

by:john M
ID: 38414245
yes i do about the same thing
thanks
pretty nuch i figure there was nothing to do to get to the data any better then your way or the way i am doing
0
 
LVL 3

Author Comment

by:john M
ID: 38415135
since i learned 2 things from your
comment - thats a good thing
Thanks
enjoy the points

For i As Integer = 2 to 14 Step 4
     txt = panel1.Controls(i)
Next
0
 
LVL 3

Author Closing Comment

by:john M
ID: 38415136
Thanks
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question