Reputation:
I have tried to create a custom picturebox which I want to show only when data is loading into datagridview, but not successfully.
What I'm doing wrong. This is an example of my code.
'creating picturebox
pic.CreateControl()
pic.Visible = True
pic.Width = 222
pic.Height = 173
Dim x As Integer = 602
Dim y As Integer = 207
pic.ImageLocation = ("C:\index.jpg")
pic.Load()
pic.Name = "Obavjestenje"
pic.Size = New System.Drawing.Size(264, 200)
pic.TabIndex = 900
pic.TabStop = False
pic.Show()
'filing data into dataset
dsFilter = New DataSet
myCommandLoad = New SqlCommand(workerSQL, conn)
myCommandLoad.CommandTimeout = 200
adapterLoad.SelectCommand = myCommandLoad
adapterLoad.Fill(dsFilter)
adapterLoad.Dispose()
myCommandLoad.Dispose()
' binding dataset and datagrid
If dsFilter.Tables(0).Rows.Count > 0 Then
pic.Dispose()
GridControl1.DataSource = dsFilter.Tables(0)
' at this point I don't whant to see picturebox while my data is uploaded
Pic.Visible = False
End Sub
Upvotes: 0
Views: 749
Reputation: 7214
Try
Dim pic As New PictureBox
pic.Width = 222
pic.Height = 173
pic.Location = New Point(?, ?)
pic.ImageLocation = "C:\index.jpg"
pic.Load()
pic.Visible = True
Me.Controls.Add(pic)
pic.Refresh()
'filing data into dataset
...
or better
Using pic = New PictureBox
pic.Width = 222
pic.Height = 173
pic.Location = New Point(?, ?)
pic.ImageLocation = "C:\index.jpg"
pic.Load()
pic.Visible = True
Me.Controls.Add(pic)
pic.Refresh()
'filing data into dataset
...
...
End Using
You dont need pic.Visible = False or dispose
in the end.
valter
Upvotes: 1