using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;namespace StudentManagementSystem
{
public partial class AddCourse : Form
{
public AddCourse()
{
InitializeComponent();
}
private string AddCourConnStr = "workstation id=localhost;Integrated Security=SSPI;database=StuMagSys";
private SqlConnection AddCourConn;
private string AddCourSql;
private SqlCommandBuilder AddCourComm;
private SqlDataAdapter AddCourDA;
private DataSet AddCourseset = new DataSet(); private void AddCourse_Load(object sender, EventArgs e)
{
AddCourSql = "select Course_name as 课程名,credit as 学分 from course";
this.AddCourConn = new SqlConnection(this.AddCourConnStr);
this.AddCourDA = new SqlDataAdapter(this.AddCourSql, this.AddCourConn);
AddCourseset.Clear();
this.AddCourDA.Fill(AddCourseset, "Course");
CourList.DataSource = AddCourseset.Tables[0]; } private void ChgCour_Click(object sender, EventArgs e)
{
try
{
int row = this.CourList.CurrentCell.RowNumber;
this.CourList.CurrentCell = new DataGridCell(row + 1, 0);
if (AddCourseset.HasChanges())
{
this.AddCourConn = new SqlConnection(this.AddCourConnStr);
this.AddCourDA = new SqlDataAdapter(this.AddCourSql, this.AddCourConn);
AddCourComm = new SqlCommandBuilder(AddCourDA);
this.AddCourDA.Update(this.AddCourseset.GetChanges(), "Course");
MessageBox.Show("保存修改成功!", "信息");
}
}
catch (Exception Ee)
{
MessageBox.Show(Ee.ToString(), "信息");
}
} private void ExitCour_Click(object sender, EventArgs e)
{
if (MessageBox.Show("您确认要退出本系统?", "确认", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
this.Close();
} private void DelCour_Click(object sender, EventArgs e)
{
int rowNumber = this.CourList.CurrentCell.RowNumber;
try
{
this.AddCourseset.Tables[0].Rows[rowNumber].Delete();
this.AddCourConn = new SqlConnection(this.AddCourConnStr);
AddCourDA = new SqlDataAdapter("'", AddCourConn);
AddCourComm = new SqlCommandBuilder(AddCourDA);
AddCourDA.Update(this.AddCourseset.GetChanges(), "Course");
MessageBox.Show("删除成功!", "信息");
}
catch
{ }
} private void AddCour_Click(object sender, EventArgs e)
{
int row=this.CourList.VisibleRowCount;
this.CourList.CurrentCell=new DataGridCell(row+1,0);
} }
}
错误System.Windows.Forms.DataGridViewCell”并不包含“RowNumber”的定义 错误无法将类型“System.Windows.Forms.DataGridCell”隐式转换为“System.Windows.Forms.DataGridViewCell” 错误“System.Windows.Forms.DataGridViewCell”并不包含“RowNumber”的定义
错误“System.Windows.Forms.DataGridView”并不包含“VisibleRowCount”的定义
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;namespace StudentManagementSystem
{
public partial class AddCourse : Form
{
public AddCourse()
{
InitializeComponent();
}
private string AddCourConnStr = "workstation id=localhost;Integrated Security=SSPI;database=StuMagSys";
private SqlConnection AddCourConn;
private string AddCourSql;
private SqlCommandBuilder AddCourComm;
private SqlDataAdapter AddCourDA;
private DataSet AddCourseset = new DataSet(); private void AddCourse_Load(object sender, EventArgs e)
{
AddCourSql = "select Course_name as 课程名,credit as 学分 from course";
this.AddCourConn = new SqlConnection(this.AddCourConnStr);
this.AddCourDA = new SqlDataAdapter(this.AddCourSql, this.AddCourConn);
AddCourseset.Clear();
this.AddCourDA.Fill(AddCourseset, "Course");
CourList.DataSource = AddCourseset.Tables[0]; } private void ChgCour_Click(object sender, EventArgs e)
{
try
{
int row = this.CourList.CurrentCell.RowNumber;
this.CourList.CurrentCell = new DataGridCell(row + 1, 0);
if (AddCourseset.HasChanges())
{
this.AddCourConn = new SqlConnection(this.AddCourConnStr);
this.AddCourDA = new SqlDataAdapter(this.AddCourSql, this.AddCourConn);
AddCourComm = new SqlCommandBuilder(AddCourDA);
this.AddCourDA.Update(this.AddCourseset.GetChanges(), "Course");
MessageBox.Show("保存修改成功!", "信息");
}
}
catch (Exception Ee)
{
MessageBox.Show(Ee.ToString(), "信息");
}
} private void ExitCour_Click(object sender, EventArgs e)
{
if (MessageBox.Show("您确认要退出本系统?", "确认", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
this.Close();
} private void DelCour_Click(object sender, EventArgs e)
{
int rowNumber = this.CourList.CurrentCell.RowNumber;
try
{
this.AddCourseset.Tables[0].Rows[rowNumber].Delete();
this.AddCourConn = new SqlConnection(this.AddCourConnStr);
AddCourDA = new SqlDataAdapter("'", AddCourConn);
AddCourComm = new SqlCommandBuilder(AddCourDA);
AddCourDA.Update(this.AddCourseset.GetChanges(), "Course");
MessageBox.Show("删除成功!", "信息");
}
catch
{ }
} private void AddCour_Click(object sender, EventArgs e)
{
int row=this.CourList.VisibleRowCount;
this.CourList.CurrentCell=new DataGridCell(row+1,0);
} }
}
错误System.Windows.Forms.DataGridViewCell”并不包含“RowNumber”的定义 错误无法将类型“System.Windows.Forms.DataGridCell”隐式转换为“System.Windows.Forms.DataGridViewCell” 错误“System.Windows.Forms.DataGridViewCell”并不包含“RowNumber”的定义
错误“System.Windows.Forms.DataGridView”并不包含“VisibleRowCount”的定义
解决方案 »
- 哪儿有C#浅显易懂的多线程资料
- 请问如何分批 密发 邮件?(用System.Net.Mail)
- FormClosing怎么用啊?
- C#里如何把textBox里的值导入WORD
- 请大家多提供一些如何分批提取数据库的数据.
- 超难的水晶报表问题!!!!!!!!!!!!请各位高手一观。。。。谢谢了。
- btnDeleteChannel.Attributes.Add("onclick", "return confirm('確認刪除嗎?')");为什么第一次不执行!
- 堆还是堆栈?
- 大家帮帮忙 !!!
- 该如何随机产生10组含有10位数字的数值
- 一个算法的题目,求高手优化
- file、fileinfo、directory、directoryinfo 问题?
错误“System.Windows.Forms.DataGridViewCell”并不包含“RowNumber”的定义
只要将RowNumber改成RowIndex就可以;
int row=this.CourList.VisibleRowCount;
改成int row = this.CourList.RowCount;即可,
错误无法将类型“System.Windows.Forms.DataGridCell”隐式转换为“System.Windows.Forms.DataGridViewCell”这个问题没有解决,希望高手指点呀
“System.Windows.Forms.DataGridCell”隐式转换为“System.Windows.Forms.DataGridViewCell”
求解