1

Possible Duplicate:
How to access the object itself in With … End With

Suppose I would like to do something like this:

 With grid.Columns("Reviewed")
        CType(<the with object>, DataGridViewCheckBoxColumn).ThreeState = False
        ...
 End With

Basically, I would like to have the equivalent of the following in the above statement:

CType(grid.Columns("Reviewed"), DataGridViewCheckBoxColumn).ThreeState = False

Is there some keyword that I can use to refer to the object that I am "WITH"?

Community
  • 1
  • 1
Denis
  • 11,796
  • 16
  • 88
  • 150
  • 4
    Take a look at this post http://stackoverflow.com/questions/1152983/how-to-access-the-object-itself-in-with-end-with – PaShKa Jul 19 '12 at 17:36

1 Answers1

2

To my knowledge there is no way to do exactly that, but depending on what you are going to be doing it might just be easier to make another variable to reference that column.

Dim ReviewColumn as DataGridViewCheckBoxColumn = grid.Columns("Reviewed")
With ReviewColumn
    .ThreeState = False
    ''etc                
End With

Honestly I wouldn't even use the With block at that point.

King
  • 339
  • 1
  • 5