| Benjamin Wulfe - MS wrote: |
| 1. I *believe* (though I cannot confirm at the moment) that "auto toolbox generation" is by default turned off for this profile. You can change this in Tools->Options->WinformsDesigner->AutoToolboxPopulate |
|
That was it! Thanks Benjamin & Tabas. After activating AutoToolboxPopulate it worked perfectly. I wasn't able to add the control manually with "Choose Items" before, but now it's displayed perfectly fine in the designer.
here's the C++/CLR code:
public interface class IAsLVItem{
public: inline Windows::Forms::ListViewItem ^asItem(void);
};
public ref class ddlListView : public Windows::Forms::ListView
{
public:
ddlListView(void){}
inline void AddList(Collections::ArrayList ^itemlist){
Windows::Forms::ListViewItem ^item = gcnew Windows::Forms::ListViewItem();
bool isUnique;
for(int idx=0;idx<itemlist->Count;idx++){
item = ((IAsLVItem ^)itemlist[idx])->asItem();
isUnique = true;
for(int j=0;j < this->Items->Count;j++){
if(this->Items[j]->Name->Equals(item->Name)){
isUnique = false;
for (int k=0;k<this->Items[j]->SubItems->Count;k++){
this->Items[j]->SubItems[k]->Text = item->SubItems[k]->Text;
}
break;
}
}
if(isUnique) this->Items->Add(item);
}
}
inline void AddItem(IAsLVItem ^itemobj){
Windows::Forms::ListViewItem ^item = gcnew Windows::Forms::ListViewItem();
bool isUnique = true;
item = itemobj->asItem();
for(int idx=0;idx < this->Items->Count;idx++){
if(this->Items[idx]->Name->Equals(item->Name)){
isUnique = false;
for (int j=0;j<this->Items[idx]->SubItems->Count;j++){
this->Items[idx]->SubItems[j]->Text = item->SubItems[j]->Text;
}
break;
}
}
if(isUnique) this->Items->Add(item);
}
inline void UpdateItem(IAsLVItem ^itemobj){
Windows::Forms::ListViewItem ^item = gcnew Windows::Forms::ListViewItem();
item = itemobj->asItem();
for(int idx=0;idx < this->Items->Count;idx++){
if(this->Items[idx]->Name->Equals(item->Name)){
for (int j=0;j<this->Items[idx]->SubItems->Count;j++){
this->Items[idx]->SubItems[j]->Text = item->SubItems[j]->Text;
}
break;
}
}
}
inline void CheckWithList(Collections::ArrayList ^itemlist){
Windows::Forms::ListViewItem ^item = gcnew Windows::Forms::ListViewItem();
bool isObsolete;
for (int idx=(this->Items->Count - 1);idx>=0;idx--){
isObsolete = true;
for (int j=0;j<itemlist->Count;j++){
item = ((IAsLVItem ^)itemlist[j])->asItem();
if(this->Items[idx]->Name->Equals(item->Name)){
isObsolete=false;
break;
}
}
if(isObsolete) this->Items->RemoveAt(idx);
}
}
};
Edit: Looks like this forum doesn't like the letter 'i' in square brackets... hope I didn't forget to change any i's when copying the code.