rehan.azher
Member
- Joined
- Jan 1, 2009
- Messages
- 11
- Programming Experience
- Beginner
Dear Experts,
I have one form with TabControl on which i need to add/remove on same position about 37 labels and buttons after each time user click a button, bases on selection .
Problem i am facing is that when I click the button it creates the new controls and removes the old controls set, but graphics of old controls is not removed on first click , I need to select same criteria 5 to 6 times and each time graphics of controls is changed partially .
I am using following code to remove the controls :
for Adding Control I am Using following Code:
Note again controls are removed but thier graphics still appear on the form. some method that can repaint my tabcontrol graphics.
I have one form with TabControl on which i need to add/remove on same position about 37 labels and buttons after each time user click a button, bases on selection .
Problem i am facing is that when I click the button it creates the new controls and removes the old controls set, but graphics of old controls is not removed on first click , I need to select same criteria 5 to 6 times and each time graphics of controls is changed partially .
I am using following code to remove the controls :
VB.NET:
For Each ctl As Control In Me.TabControl1.TabPages(0).Controls
If TypeName(ctl) = "Button" Or TypeName(ctl) = "Label" Then
Me.TabControl1.TabPages(0).Controls.Remove(ctl)
End If
Next
for Adding Control I am Using following Code:
VB.NET:
temp(j) = New Label
temp(j).Location = New System.Drawing.Point(500, y)
temp(j).Size = New System.Drawing.Size(150, 20)
temp(j).TextAlign = ContentAlignment.MiddleLeft
temp(j).ForeColor = System.Drawing.Color.Black
temp(j).BorderStyle = BorderStyle.FixedSingle
temp(j).BackColor = System.Drawing.Color.LightSalmon
temp(j).Text = j & ": " & .myDataset.Tables(0).Rows(i)(2)
Me.TabControl1.TabPages(0).Controls.Add(temp(j))
temp2(j) = New Button
temp2(j).Location = New System.Drawing.Point(650, y)
temp2(j).Size = New System.Drawing.Size(60, 20)
temp2(j).TextAlign = ContentAlignment.MiddleCenter
temp2(j).ForeColor = System.Drawing.Color.Black
temp2(j).BackColor = System.Drawing.Color.LightBlue
temp2(j).Text = "Edit Board"
temp2(j).Name = j
Me.TabControl1.TabPages(0).Controls.Add(temp2(j))
AddHandler temp2(j).Click, AddressOf Button_Click
Note again controls are removed but thier graphics still appear on the form. some method that can repaint my tabcontrol graphics.
Last edited by a moderator: