Results 1 to 10 of 10

Thread: [RESOLVED] [2005] Getting data back from a user control to a parent control

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Resolved [RESOLVED] [2005] Getting data back from a user control to a parent control

    Hello,

    I have a user control. See the image below. The tab control is not part of the user control. but everything inside is.

    When a user wants to delete a task the taskID is taken from the tab name and passed to the user control in a public property. So I know what task I want to delete.
    Code:
    'Code in the user control
    Public Property TaskID() As Integer
            Get
                Return _taskID
            End Get
            Set(ByVal value As Integer)
                _taskID = value
            End Set
        End Property
    '
    Code:
    In the parent form I get the TaskID from the tab name and pass it to the public property
    Private Sub TabControl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.Click
            Try
                Dim taskID As Integer = 0
    
                taskID = Integer.Parse(Me.TabControl1.SelectedTab.Name)
                newTask.TaskID = taskID
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End Sub
    But the problem is when I delete I want to be sure that the deletion was successful and pass this back to the parent control. And that is something I can't see to do.

    For example: if there was a problem with the delete then I don't want to delete the tab but inform the user there was a problem.

    Code:
    'code in the user control for deleting the task, but if not successful, how do i send this back to the parent control?
    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
            Try
                Dim rowsAffected As Integer = 0
                rowsAffected = Me.TA_IncidentTask1.DeleteTask(_taskID)
                If (rowsAffected = 0) Then
                   'Not successful so how do i inform the user
                End If
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End Sub
    I am ok at passing information to the user control by using public properties as you have seen in the code above. But i need to know if the delete was successful or not.

    Can anyone help and advice me on this. code examples would be most grateful.

    Many thanks,
    Attached Images Attached Images  
    steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width