using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data.SQLite;
using System.IO;
using System.Windows.Forms;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
private SQLiteConnection con;
private SQLiteCommand cmd;
private DataTable dt;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
con = new SQLiteConnection();
con.ConnectionString = @"Data Source=cyber.db;New=False;Version=3";
cmd = new SQLiteCommand();
cmd.Connection = con;
dt = new DataTable();
dataGridView1.DataSource = dt;
con.Open();
cmd.CommandText = "SELECT * FROM example";
dt.Clear();
dt.Load(cmd.ExecuteReader());
con.Close();
if (dataGridView1.Columns[0].HeaderText == "id")
{
dataGridView1.Columns[0].HeaderText = "Код";
}
if (dataGridView1.Columns[1].HeaderText == "value")
{
dataGridView1.Columns[1].HeaderText = "Наименование";
}
}
private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
int currentRow = dataGridView1.CurrentRow.Index; // номер строки, по которой кликнули
MessageBox.Show("Вы жмякнули по строке содержащей - " + dataGridView1[1, currentRow].Value.ToString());
}
}
}