daily pastebin goal
5%
SHARE
TWEET

Untitled

a guest Oct 16th, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11.  
  12. namespace WindowsFormsApplication1
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         private const string path = "test.txt";
  17.         protected int currentnumber = 0;
  18.         protected const int max_num = 5;
  19.         protected const int size = 5;
  20.         public ankieta[] tab = new ankieta[max_num];
  21.  
  22.         public struct ankieta
  23.         {
  24.             public string[] str;
  25.             public int selectedNumber;
  26.             public ankieta(string[] st1)
  27.             {
  28.                 this.str = st1;
  29.                 this.selectedNumber = 0;
  30.             }
  31.  
  32.         }
  33.  
  34.         private void Form1_Load(object sender, EventArgs e)
  35.         {
  36.             for(int i = 0; i < max_num; i++)
  37.             {
  38.                 tab[i].str = new string[5];
  39.             }
  40.             using (StreamReader sr = new StreamReader(path))
  41.             {
  42.                 string line;
  43.                 int j = 0, p = 0;
  44.                 while((line = sr.ReadLine()) != null)
  45.                 {
  46.                     tab[p].str[j] = line;
  47.  
  48.                     j++;
  49.                     if (j % 5 == 0)
  50.                     {
  51.                         j = 0;
  52.                         p++;
  53.                     }
  54.                 }
  55.             }
  56.             InputText(currentnumber);
  57.         }
  58.  
  59.         public void InputText(int num)
  60.         {
  61.             if (num < 0 || num > max_num) return;
  62.             textBox1.Text = tab[num].str[0];
  63.             radioButton1.Text = tab[num].str[1];
  64.             radioButton2.Text = tab[num].str[2];
  65.             radioButton3.Text = tab[num].str[3];
  66.             radioButton4.Text = tab[num].str[4];
  67.  
  68.             radioButton1.Checked = false;
  69.             radioButton2.Checked = false;
  70.             radioButton3.Checked = false;
  71.             radioButton4.Checked = false;
  72.  
  73.         }
  74.  
  75.  
  76.  
  77.         public Form1()
  78.         {
  79.             InitializeComponent();
  80.         }
  81.  
  82.         private void button4_Click(object sender, EventArgs e)
  83.         {
  84.             if (!button1.Enabled) button1.Enabled = true;
  85.             if (currentnumber + 1 < max_num) InputText(++currentnumber);
  86.             else button4.Enabled = false;
  87.         }
  88.  
  89.         private void button1_Click(object sender, EventArgs e)
  90.         {
  91.             if(!button4.Enabled) button4.Enabled = true;
  92.             if (currentnumber - 1 > 0) InputText(--currentnumber);
  93.             else button1.Enabled = false;
  94.         }
  95.  
  96.         private void button2_Click(object sender, EventArgs e)
  97.         {
  98.  
  99.         }
  100.  
  101.         private void radioButton1_CheckedChanged(object sender, EventArgs e)
  102.         {
  103.             tab[currentnumber].selectedNumber = 1;
  104.         }
  105.  
  106.         private void radioButton2_CheckedChanged(object sender, EventArgs e)
  107.         {
  108.             tab[currentnumber].selectedNumber = 2;
  109.         }
  110.  
  111.         private void radioButton3_CheckedChanged(object sender, EventArgs e)
  112.         {
  113.             tab[currentnumber].selectedNumber = 3;
  114.         }
  115.  
  116.         private void radioButton4_CheckedChanged(object sender, EventArgs e)
  117.         {
  118.             tab[currentnumber].selectedNumber = 4;
  119.         }
  120.     }
  121. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top