Click here to Skip to main content
15,564,475 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace lllllllll
{
public partial class Form2 : Form
{
public Form2( string Item_no, string Item_name, string Description,string Price)
{
InitializeComponent();

dataGridView1.Rows.Add();

dataGridView1.Rows[0].Cells[0].Value = Item_no;
dataGridView1.Rows[0].Cells[1].Value = Item_name;
dataGridView1.Rows[0].Cells[2].Value = Description;
dataGridView1.Rows[0].Cells[3].Value = Price;

}

private void Form2_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dataDataSet1.Items' table. You can move, or remove it, as needed.
this.itemsTableAdapter.Fill(this.dataDataSet1.Items);

}
}
}


What I have tried:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace lllllllll
{
public partial class Form2 : Form
{
public Form2( string Item_no, string Item_name, string Description,string Price)
{
InitializeComponent();

dataGridView1.Rows.Add();

dataGridView1.Rows[0].Cells[0].Value = Item_no;
dataGridView1.Rows[0].Cells[1].Value = Item_name;
dataGridView1.Rows[0].Cells[2].Value = Description;
dataGridView1.Rows[0].Cells[3].Value = Price;

}

private void Form2_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dataDataSet1.Items' table. You can move, or remove it, as needed.
this.itemsTableAdapter.Fill(this.dataDataSet1.Items);

}
}
}
Posted
Updated 25-Nov-17 10:57am

1 solution

Yeah? What part of that message doesn't make sense?

You can add rows manually, with dgv.Rows[]... or you can bind the grid to a DataSet or DataTable, but you can't do both. So, you either have to manually add all the rows to the DGV (time consuming and cumbersome!) or you can add the rows to the data that the drig is bound to.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900