VB.NET Nested With statements from different scopes

后端 未结 2 1911
天涯浪人
天涯浪人 2021-01-22 09:44

I am wondering if this is possible. I have a List Table (lstTable) that is on the same form that I am trying to fill in with information from a public structure (ELEM_DATA). I

2条回答
  •  孤城傲影
    2021-01-22 10:11

    Nested With statements work (see comment about conflicts). Unfortunately you can't use the outer members inside the inner with. But since your outer WITH is a refernce type you could use a local variable to "alias" it as you suggest in you comment.

    Dim l = me.lstTable.Items(RECORD) ' requires 2008 and option infer
    With ELEM_DATA(RECORD)
       l.SubItems(1).text = .name
    End With
    

    Here's a link to show how nested WITH statements can used.

    http://ideone.com/agjne

提交回复
热议问题