Kshitij Bhatia

Kshitij Bhatia

  • NA
  • 22
  • 4.3k

Change the cell position of the Panel dynamically

Apr 19 2018 1:12 AM
Hello,
 
I want to change the cell position of the panel at runtime through programmatically, I have Used TableLayoutPanel And for inserting the records into cell i have used panel in each cell.
 
Here is my code
  1. Dim c1 As New Control  
  2. Dim c2 As New Control  
  3. MainTableLayoutPanel1 = TryCast(c1.Parent, TableLayoutPanel)  
  4. If MainTableLayoutPanel1 Is c2.Parent Then 'AndAlso MainTableLayoutPanel1 IsNot Nothing Then  
  5. Dim PosC1 As TableLayoutPanelCellPosition = MainTableLayoutPanel1.GetCellPosition(c1)  
  6. Dim PosC2 As TableLayoutPanelCellPosition = MainTableLayoutPanel1.GetCellPosition(c2)  
  7. MainTableLayoutPanel1.GetCellPosition(PnlLinegraph)  
  8. MainTableLayoutPanel1.GetCellPosition(PnlDoughnutChart)  
  9. c1 = PnlLinegraph  
  10. c2 = PnlDoughnutChart  
  11. MainTableLayoutPanel1.SetCellPosition(c2, PosC1)  
  12. MainTableLayoutPanel1.SetCellPosition(c1, PosC2)  
  13. End If  
does any one have better solution on it....?
 
I have got an error (Object Reference not set to an instance of the object)