Hello,
I have trying to get the controls that are on a user control. The user control has been placed on a tab. I am looping through the tabs getting the controls so I can get the values that have been input in that control.
In .Net 2.0 you can do this:
But in the CF it is getting the values is more of a problem. I have trying very hard to do this in CF.Code:'Get the user control on this tab uc = tp.Controls("QuickIncidentTasks") 'Get all the details for the controls contained the in user control in the current tab. scheduledDate = uc.Controls("dtScheduledDate")
Many thanks for any assistance,
Code:Try 'All the controls that are on the user control Dim taskDetails As New Windows.Forms.TextBox Dim completionNotes As New Windows.Forms.TextBox Dim users As New ComboBox Dim supportType As New ComboBox Dim status As New ComboBox Dim scheduledDate As New Windows.Forms.DateTimePicker Dim scheduledTime As New Windows.Forms.DateTimePicker Dim taskID As Integer = 0 Dim uc As Control Dim rowsAffected As Integer = 0 'Loop through all the tab and get the user control For Each tp As TabPage In Me.tbcTasks.TabPages 'Get the user control on this tab uc = tp.Controls(0) 'Get all the details for the controls contained the in user control in the current tab. 'Trail and error below - so a bit of a mess 'scheduledDate.Value = CDate(uc.Controls(3).Text) 'scheduledTime.Value = CDate(uc.Controls(4).Text) taskDetails = DirectCast(uc.Controls.Item(4), TextBox) taskDetails.Text = uc.Controls(8).ToString() completionNotes.Text = uc.Controls(9).Text users.Text = uc.Controls(5).ToString() supportType.Text = uc.Controls(6).ToString() status.Text = uc.Controls(7).ToString() 'Get the taskID number of the task on the tab taskID = CInt(tp.Name) Next tp Catch ex As Exception MsgBox(ex.ToString()) End Try




Reply With Quote