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 PropertyBut 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.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
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.
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.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
Can anyone help and advice me on this. code examples would be most grateful.
Many thanks,




Reply With Quote