Advertisement
BZIKowaty

zadanie 3 programowanie

Oct 25th, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  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.Windows.Forms;
  9.  
  10. namespace My_DataGridView
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.  
  19.         private void button1_Click(object sender, EventArgs e)
  20.         {
  21.             Int16 M, N;
  22.             double Sum;
  23.             M = Convert.ToInt16(numericUpDown1.Value);
  24.             N = Convert.ToInt16(numericUpDown2.Value);
  25.             Sum = 0;
  26.             for (int i = 0; i < M; i++)
  27.                 for (int j = 0; j < N; j++)
  28.                 {
  29.                     Sum = Sum + Convert.ToDouble(dataGridView1.Rows[i].Cells[j].Value);
  30.                 }
  31.             textBox1.Text = Convert.ToString(Sum);
  32.         }
  33.  
  34.         private void button2_Click(object sender, EventArgs e)
  35.         {
  36.             Int16 M, N;
  37.             M = Convert.ToInt16(numericUpDown1.Value);
  38.             N = Convert.ToInt16(numericUpDown2.Value);
  39.             for (int i = 0; i < M; i++)
  40.                 for (int j = 0; j < N; j++)
  41.                 {
  42.                    dataGridView1.Rows[i].Cells[j].Value=" ";
  43.                 }
  44.             textBox1.Text =" ";
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement