How to make a DataGridview In C# like SQL Server
How to make a DataGridview In C# like SQL Server. I want to bind the data with datagrid and i want to edit and update using that gridview only.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Freddy AbreuPosted Apr 2, 2013, 4:45 PM
Bye.
Freddy AbreuPosted Apr 2, 2013, 2:59 PM
1-First the class.
Let's suppose we are creating a program for a Warehouse, we need the class for the product, the warehouse etc... let's see:
But first you have to start with some codes at least, that's in case you want to learn by your own.
public class Almacen
{
private string wharehouse;
public Almacen(string wharehouse )
{
this.wharehouse = wharehouse;
}
public string Wharehouse
{
get{return wharehouse;}
set{wharehouse = value;}
}
}
}
--------------------------------------------------------------------------------------
main program
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace DataGridHelp
{
///
/// Description of MainForm.
///
public partial class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void Button3Click(object sender, EventArgs e)
{
//to delete, you have to do it.
}
List
List
List
void MainFormLoad(object sender, EventArgs e)
{
Producto pro = new Producto("Cell");
productos.Add(pro);
pro = new Producto("Pollo");
productos.Add(pro);
dataGridView1.AutoGenerateColumns = false;
DataGridViewTextBoxColumn productColumn = new DataGridViewTextBoxColumn();
productColumn.DataPropertyName = "Product";
productColumn.HeaderText = "Producto";
dataGridView1.Columns.Add(productColumn);
comboBox1.DataSource = productos;
comboBox1.DisplayMember = "Productnombre";
comboBox1.ValueMember = "Productnombre";
}
void Button1Click(object sender, EventArgs e)
{
}
void Button2Click(object sender, EventArgs e)
{
this.dataGridView1.Update();
}
void Button4Click(object sender, EventArgs e)
{
Form1 Ventana = new Form1();
Ventana.Show();
}
void Button5Click(object sender, EventArgs e)
{
Form2 ventanita = new Form2();
ventanita.Show();
}
void Button6Click(object sender, EventArgs e)
{
Form3 ventanaEmergente = new Form3();
ventanaEmergente.Show();
}
}
}
--------------------------
But a feel sorry man you have to start first, I told you there are many ways.