CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    ListItem how to create ?

    Hi all !
    I'm just on a new activeX and want to make it compatible to a lot of MS activeX This way I wanted to use ListItem as a class for my listdata. That would make it easy to exchange data when I can use the same class as well as e.g for a ListView and for my activeX. like
    Code:
    myControl.Drophighlight = ListCtrl.SelectedItem
    where myControl is the new activeX and ListCtrl is any MS listView
    contrl.

    Problem is if I want to create a ListItem like
    Code:
    Private m_myList as ListItem
    ...
    Set m_MyList = new ListItem
    it errors and told me I cannot create this class
    So maybe I only need to add e reference to the code but I didn't know which. Adding an invisible control allows to use ListItem as a pointer
    like
    Code:
    Dim myList as ListItem
    Set myList = ListView.SelectedItem
    So it gets the object out of the listview, but it still doesn't allow to create an ListItemobject myself. ? Any one knows why and what to do against ?

    Thx in before
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  2. #2
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    516

    Re: ListItem how to create ?

    My guess is that the ListItem keeps a private reference to it's Parent object, and that there isn't really an exposed way to VB to set the Parent reference. This could be why it won't allow you to create a 'parentless' ListItem. One thing to try that pops into my head is to create a mirror object that implements the ListItem interface and then pass it back and forth using iDispatch?

    Of course, you've already mentioned the easiest solution--using a hidden ListView to generate your objects.

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: ListItem how to create ?

    If you check, there are not many objects allowed to go after a 'New' statement.

    Also, the ListItem is more or less from a dynamic size since one of its properties is the list of subitems not yet specified. Maybe the creation process for a new listitem is thus inherent in the ListView control and not available without it.

  4. #4
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: ListItem how to create ?

    Quote Originally Posted by Comintern
    My guess is that the ListItem keeps a private reference to it's Parent object, and that there isn't really an exposed way to VB to set the Parent reference. This could be why it won't allow you to create a 'parentless' ListItem. One thing to try that pops into my head is to create a mirror object that implements the ListItem interface and then pass it back and forth using iDispatch?

    Of course, you've already mentioned the easiest solution--using a hidden ListView to generate your objects.
    In that way Ireally should have done it as I wanted it to do before. As a control from a listView Control in C++. But my grid is already done ( its a grid which allows having a button, a combobox, a checkbox and a colored field and as much editable columns as you want in each row, so you can do every different combinations of this ( but only one of each sort of special fields. So I'm using it for examlple only with the button and the editfields and in onother part of my program I have a combination of a checkbox a combobox, a colorfield and some editfileds but no button.

    So this is nearly ready now, but in drag and drop in dataexchange with a listview I have now my own class for dataexchange and on the other side the listview with listitem. Easy to handle but some code, for the exchange has now to be a bit more instead of only handling the listItemobject from the one to the other . OK the next axctiveX I'll do in C++ for I' dreaming from a control, which free decision of how many buttons, editable fields,noneditable fields, comboboxes , pictures.. checkboxes it would have. But this then I think I'll di in C++ as a training this winter. ( when the nights are cold and you can better think then in this heat. ) But I think I'll give the idea a short try to use a hidden listbox as a ListItemfactiory. Hopefully the activeX will not slow down too much by this lot of code in the background or that other troubles occure when I try to use the activeX in the compiled version.
    We will see.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured