问题描述
亲爱的所有人,
我编写了一个代码,其中包含组框"和一些分配有某些颜色的复选框,以及数据网格视图表"(其中包含一些数据表).
我必须生成的输出是,每当我单击组框中的任何一个复选框时,该复选框各自的背景色应显示在数据网格视图"表中.
但是,当我编写此代码时,出现以下错误:
指向"e.Value.ToString =="无效& this.activeCustomersCheckBox.Checked
运算符" ==不能应用于方法组"和字符串"类型的操作数.
请帮我解决这个错误.等待您的答复.
这是我写的代码
Dear All,
I wrote a code that contains Group Box with some checkboxes assigned with some colors, and Data Grid View Table(that contains some data table).
The output i must generate is, whenever i click on a any one of check box in group box, that check box''s respective back color should be displayed on the Data Grid View Table.
But, When i wrote this code, i got the following error:
pointing "e.Value.ToString == "Inactive" & this.activeCustomersCheckBox.Checked
"Operator "==" cannot be applied to operands of type ''method group'' and ''string''.
please, help me with this error. Awaiting for your reply.
Here is the code which i''ve written
public class Form
{
private void Form_Load(System.Object sender, System.EventArgs e)
{
// Load data into the 'AjaxDataSet.Customer' DataTable.
this.CustomerTableAdapter.Fill(this.AjaxDataSet.Customer);
// Set customerDataGridView column names to the column names
// in the data source. (Ajax database Customer table's column names)
// This will enable us to refer to customerDataGridView columns
// by name in this form's customerDataGridView_CellFormatting method.
int i;
for (i = 0; i <= this.customerDataGridView.Columns.Count - 1; i++) {
this.customerDataGridView.Columns[i].Name = this.customerDataGridView.Columns[i].DataPropertyName;
}
// Don't allow new records to be added.
this.customerDataGridView.AllowUserToAddRows = false;
}
private void // ERROR: Handles clauses are not supported in C#
inactiveCustomersCheckBox_CheckedChanged(System.Object sender, System.EventArgs e)
{
// The Checked property of the inactiveCustomerCheckBox
// has changed - repaint the customerDataGridView.
this.customerDataGridView.Invalidate();
}
private void // ERROR: Handles clauses are not supported in C#
orderOverdueCheckBox_CheckedChanged(System.Object sender, System.EventArgs e)
{
// The Checked property of the orderOverdueCheckBox
// has changed - repaint the customerDataGridView.
this.customerDataGridView.Invalidate();
}
private void // ERROR: Handles clauses are not supported in C#
customerDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
// If the column being formatted is the column named 'Status' ..
if (this.customerDataGridView.Columns[e.ColumnIndex].Name == "Status") {
if (e.Value != null) {
// If the value of the cell is "Inactive" AND this form's inactiveCustomersCheckBox control is checked..
if (e.Value.ToString == "Inactive" & this.inactiveCustomersCheckBox.Checked) {
// Set the BackColor of the cell to yellow.
e.CellStyle.BackColor = Color.Yellow;
}
if (e.Value.ToString == "Active" & this.activeCustomersCheckBox.Checked) {
// Set the BackColor of the cell to Fuchsia
e.CellStyle.BackColor = Color.Fuchsia;
}
}
}
// If the column being formatted is the column named 'LastOrderDate'..
if (this.customerDataGridView.Columns(e.ColumnIndex).Name == "LastOrderDate") {
if (e.Value != null) {
// If LastOrderDate was more than 30 days ago AND this form's ordersOverdueCheckBox control is checked..
if (System.DateTime.Now.Subtract((System.DateTime)e.Value).Days > 30 & this.orderOverdueCheckBox.Checked) {
// Set the BackColor of the cell to yellow-green.
e.CellStyle.BackColor = Color.YellowGreen;
}
}
}
}
private void // ERROR: Handles clauses are not supported in C#
activeCustomersCheckBox_CheckedChanged(System.Object sender, System.EventArgs e)
{
// The Checked property of the activeCustomerCheckBox
// has changed - repaint the customerDataGridView.
this.customerDataGridView.Invalidate();
}
}
But, same code, when i tried to implement in Vb. The code is generating the output. I'm unable to correct this. So friends, please help me.
Regards
Indu. :doh:
推荐答案
这篇关于C#数据网格表错误,请帮助!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!