TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shesh Mishra
NA
22
32k
Solve the error in the code
Aug 1 2012 4:28 AM
Error 1 Using the generic type 'System.Collections.Generic.List<T>' requires 1 type argument Line 90 Col 13
Error 2 Using the generic type 'System.Collections.Generic.List<T>' requires 1 type argument Line 90 Col 33
Form design
Code Behind
using System.Data;
namespace SelChkRowVal
{
public partial class Form1 : Form
{
DataTable dt = new DataTable();
DataRow dr;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
loadGrid();
}
public void loadGrid()
{
dataGridView1.AllowUserToAddRows = false;
//Below i create on check box column in the datagrid view
dataGridView1.Columns.Clear();
DataGridViewCheckBoxColumn colCB = new DataGridViewCheckBoxColumn();
//set name for the check box column
colCB.Name = "chkcol";
colCB.HeaderText = "";
dataGridView1.Columns.Add(colCB);
DataTable dt = new DataTable();
DataRow dr = default(DataRow);
//Declare Column names
dt.Columns.Add("eno");
dt.Columns.Add("empname");
dt.Columns.Add("sal");
//Create rows with data
dr = dt.NewRow();
dr["eno"] = 101;
dr["empname"] = "test1";
dr["sal"] = 9000;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["eno"] = 102;
dr["empname"] = "test2";
dr["sal"] = 15000;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["eno"] = 103;
dr["empname"] = "test3";
dr["sal"] = 20000;
dt.Rows.Add(dr);
dataGridView1.DataSource = dt;
}
//Below method is used check only one checkbox in grid view
private void dataGridView1_CellClick(System.Object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
if (Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells["chkcol"].Value) == false)
{
for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
{
dataGridView1.Rows[i].Cells["chkcol"].Value = false;
}
}
}
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text="";
int i = 0;
List ChkedRow = new List();
for (i = 0; i <= dataGridView1.RowCount - 1; i++)
{
if (Convert.ToBoolean(dataGridView1.Rows[i].Cells["chkcol"].Value) == true)
{
ChkedRow.Add(i);
}
}
if (ChkedRow.Count == 0)
{
MessageBox.Show("Select atleast one checkbox");
return;
}
//Here i display all selected checkbox data in that three text boxes
foreach (int k in ChkedRow)
{
textBox1.Text = textBox1.Text + dataGridView1.Rows[k].Cells[1].Value + " ";
textBox2.Text = textBox2.Text + dataGridView1.Rows[k].Cells[2].Value + " ";
textBox3.Text = textBox3.Text + dataGridView1.Rows[k].Cells[3].Value + " ";
}
}
}
}
Reply
Answers (
2
)
Richtextbox with Image on write text and use ink to save Xml
Can we add multiple xaml page refference in .xap file in silverlight 5