C#数据网格表错误,请帮助!!!

编程入门 行业动态 更新时间:2024-10-11 21:22:22
本文介绍了C#数据网格表错误,请帮助!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

亲爱的所有人, 我编写了一个代码,其中包含组框"和一些分配有某些颜色的复选框,以及数据网格视图表"(其中包含一些数据表). 我必须生成的输出是,每当我单击组框中的任何一个复选框时,该复选框各自的背景色应显示在数据网格视图"表中. 但是,当我编写此代码时,出现以下错误: 指向"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:

推荐答案

我还没有遍历您的代码来查看它的作用,但是您正在描述的直接问题是由于未在ToString中添加括号来表示它是方法调用,即ieeValue.ToString(). I haven''t trawled through your code to look at what it''s doing yet, but the immediate problem you''re describing is caused by not adding the parenthesis to ToString to denote that it''s a method call, i.e. e.Value.ToString().

更多推荐

C#数据网格表错误,请帮助!!!

本文发布于:2023-07-09 21:16:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1088238.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   错误   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!