Ask Experts Questions for FREE Help !
Ask
    scthread's Avatar
    scthread Posts: 1, Reputation: 1
    New Member
     
    #1

    Dec 10, 2011, 03:03 PM
    Can I please get help on creating an array to fill a list box? In C
    I need help writing a C Form Program that will use 3 Parallel Arrays to store Data. I have the form set up - and the clear button working. But I am lost as to how do the rest...
    My requirements are below:
    Create a form called Eddie's Equipment Rental w/ a list box, a Duration text box, a Charge text box a display button and a clear button.
    It should look like this:


    1. Eddie charges one amount for a full day rental and another amount for half day rentals - use 3 parallel arrays to store the data
    Data is as follows:
    Equipment Rug Cleaner - Lawn Mower - Paint Sprayer
    HalfDay Charge 16 12 20
    Full Day Charge 24 18 30

    2. Load the list box during the form load event
    3. User should click on the ime in the listbox to seelct the equipment
    4. The user must enter F or H for full or half Day - add an error check
    5. The Display Charge button will display the appropriat amount in the Rental Charge text box
    6. The clear Button will Clear the 2 text boxes
    I have the form... and the clear button working. Code is below:
    <CODE>
    #pragma once

    Namespace Final {

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

    /// <summary>
    /// Summary for Form1
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
    Form1(void)
    {
    InitializeComponent();
    //
    //TODO: Add the constructor code here
    //
    }

    protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~Form1()
    {
    if (components)
    {
    delete components;
    }
    }
    private: System::Windows::Forms::ListBox^ lstEquipment;
    protected:
    private: System::Windows::Forms::Label^ lblDuration;
    private: System::Windows::Forms::TextBox^ txtDuration;
    private: System::Windows::Forms::Label^ lblCharge;
    private: System::Windows::Forms::TextBox^ txtCharge;
    private: System::Windows::Forms::Button^ btnDisplay;
    private: System::Windows::Forms::Button^ btnClear;
    private: System::Windows::Forms::Label^ lblInstruction;

    private:
    /// <summary>
    /// Required designer variable.
    /// </summary>
    System::ComponentModel::Container ^components;

    #pragma region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
    this->lstEquipment = (gcnew System::Windows::Forms::ListBox());
    this->lblDuration = (gcnew System::Windows::Forms::Label());
    this->txtDuration = (gcnew System::Windows::Forms::TextBox());
    this->lblCharge = (gcnew System::Windows::Forms::Label());
    this->txtCharge = (gcnew System::Windows::Forms::TextBox());
    this->btnDisplay = (gcnew System::Windows::Forms::Button());
    this->btnClear = (gcnew System::Windows::Forms::Button());
    this->lblInstruction = (gcnew System::Windows::Forms::Label());
    this->SuspendLayout();
    //
    // lstEquipment
    //
    this->lstEquipment->FormattingEnabled = true;
    this->lstEquipment->Items->AddRange(gcnew cli::array< System::Object^ >(3) {L"1- Rug Cleaner", L"2- Lawn Mower", L"3- Paint Sprayer"});
    this->lstEquipment->Location = System::Drawing::Point(95, 46);
    this->lstEquipment->Name = L"lstEquipment";
    this->lstEquipment->Size = System::Drawing::Size(158, 56);
    this->lstEquipment->TabIndex = 1;
    //
    // lblDuration
    //
    this->lblDuration->AutoSize = true;
    this->lblDuration->Location = System::Drawing::Point(92, 154);
    this->lblDuration->Name = L"lblDuration";
    this->lblDuration->Size = System::Drawing::Size(130, 13);
    this->lblDuration->TabIndex = 2;
    this->lblDuration->Text = L"Select a Duration (F or H):";
    //
    // txtDuration
    //
    this->txtDuration->Location = System::Drawing::Point(228, 150);
    this->txtDuration->Name = L"txtDuration";
    this->txtDuration->Size = System::Drawing::Size(34, 20);
    this->txtDuration->TabIndex = 3;
    //
    // lblCharge
    //
    this->lblCharge->AutoSize = true;
    this->lblCharge->Location = System::Drawing::Point(92, 179);
    this->lblCharge->Name = L"lblCharge";
    this->lblCharge->Size = System::Drawing::Size(78, 13);
    this->lblCharge->TabIndex = 4;
    this->lblCharge->Text = L"Rental Charge:";
    //
    // txtCharge
    //
    this->txtCharge->Location = System::Drawing::Point(176, 176);
    this->txtCharge->Name = L"txtCharge";
    this->txtCharge->Size = System::Drawing::Size(86, 20);
    this->txtCharge->TabIndex = 5;
    //
    // btnDisplay
    //
    this->btnDisplay->Location = System::Drawing::Point(74, 217);
    this->btnDisplay->Name = L"btnDisplay";
    this->btnDisplay->Size = System::Drawing::Size(75, 23);
    this->btnDisplay->TabIndex = 6;
    this->btnDisplay->Text = L"Display Charge";
    this->btnDisplay->UseVisualStyleBackColor = true;
    //
    // btnClear
    //
    this->btnClear->Location = System::Drawing::Point(221, 217);
    this->btnClear->Name = L"btnClear";
    this->btnClear->Size = System::Drawing::Size(75, 23);
    this->btnClear->TabIndex = 7;
    this->btnClear->Text = L"Clear";
    this->btnClear->UseVisualStyleBackColor = true;
    this->btnClear->Click = gcnew System::EventHandler(this, &Form1::ClearInput);
    //
    // lblInstruction
    //
    this->lblInstruction->AutoSize = true;
    this->lblInstruction->Location = System::Drawing::Point(105, 30);
    this->lblInstruction->Name = L"lblInstruction";
    this->lblInstruction->Size = System::Drawing::Size(124, 13);
    this->lblInstruction->TabIndex = 8;
    this->lblInstruction->Text = L"Click on the Item to Rent";
    //
    // Form1
    //
    this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    this->ClientSize = System::Drawing::Size(359, 264);
    this->Controls->Add(this->lblInstruction);
    this->Controls->Add(this->btnClear);
    this->Controls->Add(this->btnDisplay);
    this->Controls->Add(this->txtCharge);
    this->Controls->Add(this->lblCharge);
    this->Controls->Add(this->txtDuration);
    this->Controls->Add(this->lblDuration);
    this->Controls->Add(this->lstEquipment);
    this->Name = L"Form1";
    this->Text = L"Eddies Equipment Rental";
    this->ResumeLayout(false);
    this->PerformLayout();

    }
    #pragma endregion
    private: System::Void ClearInput(System::Object^ sender, System::EventArgs^ e)
    {
    txtDuration->Clear();
    txtCharge->Clear();

    }
    };
    }

    </CODE>

Check out some similar questions!

Creating Materials/Take-off List [ 2 Answers ]

I am in the final planning stages for an addition on my home. I will contract out the foundation, but hope to do the rest of the work myself. I have done some rough materials estimates, enough to get a feel for the costs, but now that we're heading into the final stretch, I'd like to put together...

Display array in list box [ 1 Answers ]

Hi all, How do I display a whole array in one list box? (I want it to be displayed in the form load event... is that possible?) For example I want to display these: ============================ mstrMonths(0) = "January" mstrMonths(1) = "February" mstrMonths(2) =...

Combo box/list box/drop down box [ 1 Answers ]

I have a question for you in regards to a list box in a query. I have a form that I am using and want to give the users some options on what years they want to pull data from. So I was thinking about creating a list box or drop down box that would display the available years, when they highlighted...

Creating a Category List and Results [ 3 Answers ]

Hi, I am trying to create a "Buyer's Guide". The first page - buyersguide.php will have a drop down menu that is populated with the categories (advertising, accounting, construction, etc.) from the table Categories. Once the user selects the category they are interested in, it will take them to a...


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.