dataGridView1_CellContentClick事件
public void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
string str_class;
str_class = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
count++;
this.cdTableAdapter.Adapter.SelectCommand.CommandText = "select name from cd where type=\"" + str_type + "\" and class=\"" + str_class + "\" order by code desc";
this.cdTableAdapter.Fill(this.memuDataSet.cd);
if (Rowcnt == 0)
{
this.cdTableAdapter.Adapter.SelectCommand.CommandText = "select name from cd where type=\"" + str_type + "\" and s_men=\"" + str_class + "\" or class=\"" + str_class + "\" order by code desc";
this.cdTableAdapter.Fill(this.memuDataSet.cd);
}
}我想在事件外调用调用str_class,目的是为了实现 private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.cdTableAdapter.Adapter.UpdateCommand.CommandText = "update cd set type=\"DEL\" where name=\"" + str_class + "\"";
}
部分变量
public int Rowcnt
{
get
{
return dataGridView1.RowCount;
}
}
public int count=0;
private string n
{
get
{
if (TB=="XF")
switch (count)
{ case 1: return "B";
case 2: return "C";
case 3: return "D";
case 4: return "E";
case 5: return "F";
case 6: return "G";
default: return "A";
}
else
switch (count)
{
case 1: return "A";
case 2: return "B";
case 3: return "C";
case 4: return "D";
case 5: return "E";
case 6: return "F";
default: return "";
}
}
}
public string str_type
{
get
{
if (Rowcnt == 0)
return "节目";
else
if (TB == "ST")
if (count == 0)
return "SYS";
return "菜单" + n;
}
}
public void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
string str_class;
str_class = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
count++;
this.cdTableAdapter.Adapter.SelectCommand.CommandText = "select name from cd where type=\"" + str_type + "\" and class=\"" + str_class + "\" order by code desc";
this.cdTableAdapter.Fill(this.memuDataSet.cd);
if (Rowcnt == 0)
{
this.cdTableAdapter.Adapter.SelectCommand.CommandText = "select name from cd where type=\"" + str_type + "\" and s_men=\"" + str_class + "\" or class=\"" + str_class + "\" order by code desc";
this.cdTableAdapter.Fill(this.memuDataSet.cd);
}
}我想在事件外调用调用str_class,目的是为了实现 private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.cdTableAdapter.Adapter.UpdateCommand.CommandText = "update cd set type=\"DEL\" where name=\"" + str_class + "\"";
}
部分变量
public int Rowcnt
{
get
{
return dataGridView1.RowCount;
}
}
public int count=0;
private string n
{
get
{
if (TB=="XF")
switch (count)
{ case 1: return "B";
case 2: return "C";
case 3: return "D";
case 4: return "E";
case 5: return "F";
case 6: return "G";
default: return "A";
}
else
switch (count)
{
case 1: return "A";
case 2: return "B";
case 3: return "C";
case 4: return "D";
case 5: return "E";
case 6: return "F";
default: return "";
}
}
}
public string str_type
{
get
{
if (Rowcnt == 0)
return "节目";
else
if (TB == "ST")
if (count == 0)
return "SYS";
return "菜单" + n;
}
}
解决方案 »
- 在线等,一个小算法
- x.Split('|'); 这里是单引号,如果是双引号就必须用Regex.Split(x, "\\|"); 只是哪门子规定啊?哪里有介绍?
- C#读取aspx文件如何解决runat和其中的ascx
- C#用AT指令读取短信,为什么总是显示读取短信错误,难道程序有问题,忘高手指教
- 用正则式如何取出,所需内容,取<table>中包括的<table>
- 用.NET2003打包应用程序,创建了桌面快捷方式,但是将文件拖拽到快捷方式上,无法启动应用程序
- 哪里有《《Microsoft C# Windows程序设计(上、下册)》 中文版 下载?
- c#的progressbar
- 新人求解C#控制台程序一调试就会出现两行提示
- 如何在DataGrid中直接取得其中选取的当前数据
- 什么工具测设软件性能比较好呢?
- 自定义控件的刷新问题
{ //
private string _str_class=string.Empty;
public string StrClass
{
set{_str_class=value;}
get{return _str_class;}
}
public void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
string str_class;
str_class = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
count++;
this.cdTableAdapter.Adapter.SelectCommand.CommandText = "select name from cd where type=\"" + str_type + "\" and class=\"" + str_class + "\" order by code desc";
this.cdTableAdapter.Fill(this.memuDataSet.cd);
if (Rowcnt == 0)
{
this.cdTableAdapter.Adapter.SelectCommand.CommandText = "select name from cd where type=\"" + str_type + "\" and s_men=\"" + str_class + "\" or class=\"" + str_class + "\" order by code desc";
this.cdTableAdapter.Fill(this.memuDataSet.cd);
}
this.StrClass=str_class; //这样就行了,//当然简单一点的直接定义成窗体类里面的私有变量也行
} private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.cdTableAdapter.Adapter.UpdateCommand.CommandText = "update cd set type=\"DEL\" where name=\"" + this.StrClass + "\"";
}