using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace Aplikacja
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label8_Click(object sender, EventArgs e)
{
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int row = 0;
dataGridView1.Rows.Add();
row = dataGridView1.Rows.Count-2;
dataGridView1["Im_au", row].Value = im_au_txt.Text;
dataGridView1["Naz_au",row].Value=Naz_au_txt.Text;
dataGridView1["tyt",row].Value=Tyt_txt.Text;
dataGridView1["Wyd",row].Value=Wyd_txt.Text;
dataGridView1["Im_wyp", row].Value = Im_wyp_txt.Text;
dataGridView1["Naz_wyp", row].Value = Naz_wyp_txt.Text;
dataGridView1["Nr_bib",row].Value=Nr_bib_int.Text;
dataGridView1["Ad",row].Value=miej_txt.Text+" "+"ul."+ul_txt.Text+" "+Nr_d_int.Text+" "+Kod_int.Text;
}
private void im_au_txt_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void save_Click(object sender, EventArgs e)
{
I sposob
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
if (saveFileDialog1.ShowDialog()==DialogResult.OK)
{
using (Stream s = File.Open(saveFileDialog1.FileName, FileMode.CreateNew))
using (StreamWriter sw = new StreamWriter(s))
{
sw.Write(dataGridView1);
}
}
}
private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
{
}
private void usun_Click(object sender, EventArgs e)
{
if(MessageBox.Show("Czy chcesz usunąć wybrany wiersz","Usunąć wiersz",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
{
dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
}
else
{
MessageBox.Show("Wiersz nie został usunięty", "Wiersz został usunięty", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
I jeszcze pytanie w jakim formacie powinien być plik do którego zapisuje żeby później była możliwość wczytania go do datagrid ponownie