ListViewItem and ListViewSubItem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Klaudiusz Bryja

    ListViewItem and ListViewSubItem

    Hi,

    I have some problem. I try to get ListViewSubItem type using:

    Type t = (new
    Form).GetType() .Assembly.GetTy pe("System.Wind ows.Forms.ListV iewItem.ListVie wSubItem")

    but I get t == null. I notice that I can do that using:

    Type t = (new
    Form).GetType() .Assembly.GetTy pe("System.Wind ows.Forms.ListV iewItem
    +ListViewSubIte m")

    Why I have to use "+" sign in namespace? What does it mean? Whay in
    msdn is ListViewItem.Li stViewSubItem not ListViewItem+Li stViewSubItem?

    Best regards,
    Klaudiusz
  • Peter Duniho

    #2
    Re: ListViewItem and ListViewSubItem

    On Fri, 01 Aug 2008 05:07:30 -0700, Klaudiusz Bryja
    <bryja_klaudius z@poczta.fmwrot e:
    I have some problem. I try to get ListViewSubItem type using:
    >
    Type t = (new
    Form).GetType() .Assembly.GetTy pe("System.Wind ows.Forms.ListV iewItem.ListVie wSubItem")
    >
    but I get t == null.
    What are you _really_ trying to do? That is, why do you even want the
    type?

    As far as your question goes, it seems to me that the most
    straight-forward fix is to not use Assembly.GetTyp e() at all. Just use
    the "typeof" operator:

    Type t = typeof(ListView SubItem);

    Pete

    Comment

    • Marc Gravell

      #3
      Re: ListViewItem and ListViewSubItem

      + is the token used internally to indicate nested classes, rather than
      classes within a namespace. However, there is no need to use strings here:

      Type type = typeof(System.W indows.Forms.Li stViewItem.List ViewSubItem);

      Marc

      Comment

      • Pavel Minaev

        #4
        Re: ListViewItem and ListViewSubItem

        On Aug 1, 4:07 pm, Klaudiusz Bryja <bryja_klaudi.. .@poczta.fmwrot e:
        Why I have to use "+" sign in namespace? What does it mean? Whay in
        msdn is ListViewItem.Li stViewSubItem not ListViewItem+Li stViewSubItem?
        "+" is a reflection-specific way of denoting nested classes. In C# you
        can use "." because the compiler handles this for you; however, this
        means that in C#, you cannot have a namespace that contains another
        namespace and a class with the same name (CLS forbids this as well, by
        the way). CLR itself does not restrict such a thing, however, so you
        can write it in IL and compile using ilasm, for example, and
        reflection should be able to handle any valid CLR assembly, whether it
        is generated by C# or something else, and whether it is CLS-compliant
        or not, so it had to make this explicit.

        Comment

        Working...