List Transfers : ListBox « GUI Form « Visual C++ .NET

Home
Visual C++ .NET
1.2D
2.Class
3.Collections
4.Data Type
5.Database ADO.net
6.Delegate
7.Development
8.File Directory
9.Function
10.Generics
11.GUI Form
12.Language Basics
13.Network
14.Reflection
15.Security
16.Statement
17.Structure
18.Thread
19.XML
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Visual C++ .NET » GUI Form » ListBox 
List Transfers
 

  using namespace System;
  using namespace System::ComponentModel;
  using namespace System::Collections;
  using namespace System::Windows::Forms;
  using namespace System::Data;
  using namespace System::Drawing;

  public ref class Form1 : public System::Windows::Forms::Form
  {
  public:
    Form1(void)
    {
      InitializeComponent();
    }

        System::Windows::Forms::ListBox^  LBDest;
        System::Windows::Forms::Button^  bnR2L;
        System::Windows::Forms::Button^  bnL2R;
        System::Windows::Forms::ListBox^  LBOrg;
        System::Windows::Forms::Label^  label2;
        System::Windows::Forms::Label^  label1;

    void InitializeComponent(void)
    {
            this->LBDest = (gcnew System::Windows::Forms::ListBox());
            this->bnR2L = (gcnew System::Windows::Forms::Button());
            this->bnL2R = (gcnew System::Windows::Forms::Button());
            this->LBOrg = (gcnew System::Windows::Forms::ListBox());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->SuspendLayout();
            // 
            // LBDest
            // 
            this->LBDest->FormattingEnabled = true;
            this->LBDest->Location = System::Drawing::Point(21346);
            this->LBDest->Name = L"LBDest";
            this->LBDest->SelectionMode = 
                System::Windows::Forms::SelectionMode::MultiSimple;
            this->LBDest->Size = System::Drawing::Size(134134);
            this->LBDest->TabIndex = 10;
            this->LBDest->DoubleClick += 
                gcnew System::EventHandler(this, &Form1::LBDest_DoubleClick);
            // 
            // bnR2L
            // 
            this->bnR2L->Location = System::Drawing::Point(167108);
            this->bnR2L->Name = L"bnR2L";
            this->bnR2L->Size = System::Drawing::Size(3320);
            this->bnR2L->TabIndex = 9;
            this->bnR2L->Text = L"<==";
            this->bnR2L->Click += 
                gcnew System::EventHandler(this, &Form1::bnR2L_Click);
            // 
            // bnL2R
            // 
            this->bnL2R->Location = System::Drawing::Point(16780);
            this->bnL2R->Name = L"bnL2R";
            this->bnL2R->Size = System::Drawing::Size(3320);
            this->bnL2R->TabIndex = 8;
            this->bnL2R->Text = L"==>";
            this->bnL2R->Click += 
                gcnew System::EventHandler(this, &Form1::bnL2R_Click);
            // 
            // LBOrg
            // 
            this->LBOrg->FormattingEnabled = true;
            this->LBOrg->Items->AddRange(gcnew cli::array< System::Object^>(10)
                {L"System", L"System::Collections", L"System::Data"
                 L"System::Drawing", L"System::IO", L"System::Net"
                 L"System::Threading", L"System::Web"
                 L"System::Windows::Forms", L"System::Xml"});

            this->LBOrg->Location = System::Drawing::Point(2046);
            this->LBOrg->Name = L"LBOrg";
            this->LBOrg->SelectionMode = 
                System::Windows::Forms::SelectionMode::MultiExtended;
            this->LBOrg->Size = System::Drawing::Size(133134);
            this->LBOrg->Sorted = true;
            this->LBOrg->TabIndex = 6;
            this->LBOrg->DoubleClick += 
                gcnew System::EventHandler(this, &Form1::LBOrg_DoubleClick);
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(21317);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(10413);
            this->label2->TabIndex = 7;
            this->label2->Text = L"Unsorted Multisimple";
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(2017);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(10713);
            this->label1->TabIndex = 5;
            this->label1->Text = L"Sorted Multiextended";
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(613);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(367196);
            this->Controls->Add(this->LBDest);
            this->Controls->Add(this->bnR2L);
            this->Controls->Add(this->bnL2R);
            this->Controls->Add(this->LBOrg);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->label1);
            this->Name = L"Form1";
            this->Text = L"List Box Transfers";
            this->ResumeLayout(false);
            this->PerformLayout();
    }
        System::Void LBOrg_DoubleClick(System::Object^ sender, 
                                       System::EventArgs^ e)
        {
            if (LBOrg->SelectedItem != nullptr)
            {
                LBDest->Items->Add(LBOrg->SelectedItem)
                LBOrg->Items->Remove(LBOrg->SelectedItem)
            }
        }

        System::Void LBDest_DoubleClick(System::Object^ sender, 
                                        System::EventArgs^ e)
        {
            if (LBDest->SelectedItem != nullptr)
            {
                LBOrg->Items->Add(LBDest->SelectedItem)
                LBDest->Items->Remove(LBDest->SelectedItem)
            }
        }

        System::Void bnL2R_Click(System::Object^ sender, System::EventArgs^ e)
        {
            array<Object^>^ tmp = 
                gcnew array<Object^>(LBOrg->SelectedItems->Count)
            LBOrg->SelectedItems->CopyTo(tmp, 0)
            LBDest->Items->AddRange(tmp)
            for (int i = 0; i < tmp->Length; i++
                LBOrg->Items->Remove(tmp[i])
        }

        System::Void bnR2L_Click(System::Object^ sender, System::EventArgs^ e)
        {
            array<Object^>^ tmp = 
                gcnew array<Object^>(LBDest->SelectedItems->Count);
            LBDest->SelectedItems->CopyTo(tmp, 0)
            LBOrg->Items->AddRange(tmp)
            for (int i = 0; i < tmp->Length; i++
                LBDest->Items->Remove(tmp[i])
       }
  };



[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
  // Enabling Windows XP visual effects before any controls are created
  Application::EnableVisualStyles();
  Application::SetCompatibleTextRenderingDefault(false)

  // Create the main window and run it
  Application::Run(gcnew Form1());
  return 0;
}

   
  
Related examples in the same category
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.