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)
{
this.CustomerTableAdapter.Fill(this.AjaxDataSet.Customer);
int i;
for (i = 0; i <= this.customerDataGridView.Columns.Count - 1; i++) {
this.customerDataGridView.Columns[i].Name = this.customerDataGridView.Columns[i].DataPropertyName;
}
this.customerDataGridView.AllowUserToAddRows = false;
}
private void
inactiveCustomersCheckBox_CheckedChanged(System.Object sender, System.EventArgs e)
{
this.customerDataGridView.Invalidate();
}
private void
orderOverdueCheckBox_CheckedChanged(System.Object sender, System.EventArgs e)
{
this.customerDataGridView.Invalidate();
}
private void
customerDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (this.customerDataGridView.Columns[e.ColumnIndex].Name == "Status") {
if (e.Value != null) {
if (e.Value.ToString == "Inactive" & this.inactiveCustomersCheckBox.Checked) {
e.CellStyle.BackColor = Color.Yellow;
}
if (e.Value.ToString == "Active" & this.activeCustomersCheckBox.Checked) {
e.CellStyle.BackColor = Color.Fuchsia;
}
}
}
if (this.customerDataGridView.Columns(e.ColumnIndex).Name == "LastOrderDate") {
if (e.Value != null) {
if (System.DateTime.Now.Subtract((System.DateTime)e.Value).Days > 30 & this.orderOverdueCheckBox.Checked) {
e.CellStyle.BackColor = Color.YellowGreen;
}
}
}
}
private void
activeCustomersCheckBox_CheckedChanged(System.Object sender, System.EventArgs e)
{
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: