| |

VerySource

 Forgot password?
 Register
Search
View: 648|Reply: 1

I would like to ask the calculation of data

[Copy link]

4

Threads

10

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 Taiwan

Post time: 2020-1-22 23:40:01
| Show all posts |Read mode
Seniors

Sorry ~ brother is new to BCB

Would you like me to design a PageControl with a total of 3 TabSheet

TabSheet1 has 3 options
A (10 points)
B (5 points)
C (1 point)

TabSheet2 has 5 options
A (10 points)
B (7 points)
C (5 points)
D (3 points)
E (1 point)

TabSheet3 comes to show the calculated value of these two Sheet

How can I design such a program?

Thank you
Reply

Use magic Report

0

Threads

27

Posts

24.00

Credits

Newbie

Rank: 1

Credits
24.00

 China

Post time: 2020-2-23 10:15:01
| Show all posts
#ifndef Unit1H
    #define Unit1H
    #include <Classes.hpp>
    #include <ComCtrls.hpp>
    #include <Controls.hpp>
    #include <StdCtrls.hpp>
    class TForm1: public TForm
    {
      __published:
        TPageControl * PageControl1;
        TTabSheet * TabSheet1;
        TTabSheet * TabSheet2;
        TTabSheet * TabSheet3;
        TRadioButton * A1;
        TRadioButton * B1;
        TRadioButton * C1;
        TRadioButton * A2;
        TRadioButton * B2;
        TRadioButton * C2;
        TRadioButton * D2;
        TRadioButton * E2;
        void __fastcall PageControl1Change (TObject * Sender);
        void __fastcall func (TObject * Sender);
      public:
        __fastcall TForm1 (TComponent * Owner);
    };
    // ------------------------------------------------ ---------------------------
    extern PACKAGE TForm1 * Form1;
    // ------------------------------------------------ ---------------------------
    #endif
// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    #include <vcl.h>
    #pragma hdrstop
    #include "Unit1.h"
    #pragma package (smart_init)
    #pragma resource "* .dfm"
    TForm1 * Form1;
    // ------------------------------------------------ ---------------------------
    __fastcall TForm1 :: TForm1 (TComponent * Owner)
    : TForm (Owner)
    {
      A1-> Checked = true;
      A2-> Checked = true;
      A1-> Tag = 1;
      B1-> Tag = 2;
      C1-> Tag = 3;
      A2-> Tag = 4;
      B2-> Tag = 5;
      C2-> Tag = 6;
      D2-> Tag = 7;
      E2-> Tag = 8;
      A1-> OnClick = func;
      B1-> OnClick = func;
      C1-> OnClick = func;
      A2-> OnClick = func;
      B2-> OnClick = func;
      C2-> OnClick = func;
      D2-> OnClick = func;
      E2-> OnClick = func;
    }
    // ------------------------------------------------ ---------------------------
    void __fastcall TForm1 :: PageControl1Change (TObject * Sender)
    {
      if (PageControl1-> ActivePageIndex == 2)
      {
        TabSheet3-> Caption =
        TabSheet1-> Caption.ToIntDef (0)
        + TabSheet2-> Caption.ToIntDef (0);
      }
    }
    // ------------------------------------------------ ---------------------------
    void __fastcall TForm1 :: func (TObject * Sender)
    {
      TRadioButton * radioButton;
      radioButton = (TRadioButton *) Sender;
      if (! radioButton-> Checked) return;
      switch (radioButton-> Tag)
      {
        case 1: TabSheet1-> Caption = 10; break;
        case 2: TabSheet1-> Caption = 5; break;
        case 3: TabSheet1-> Caption = 1; break;
        case 4: TabSheet2-> Caption = 10; break;
        case 5: TabSheet2-> Caption = 7; break;
        case 6: TabSheet2-> Caption = 5; break;
        case 7: TabSheet2-> Caption = 3; break;
        case 8: TabSheet2-> Caption = 1; break;
      }
    }
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list