本文介绍了DataGridView显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我的代码是: My CODE IS:Dim strSQL6 As String = "SELECT Regno, SName, SUM(AmountPaid), FeeType, Class, Section FROM FeeTrans where class='" & cboClass.Text & "' and section='" & cboSection.Text & "' and FeeType='" & cboFeeType.Text & "' GROUP BY Regno, SName, FeeType, Class, Section" Dim DaAp6 As New SqlDataAdapter(strSQL6, con) Dim DSet6 As New DataTable DaAp6.Fill(DSet6) '======================================== With Me.DataGridView1 .Columns.Add("Regno", "RegNo") .Columns.Add("SName", "Student Name") .Columns.Add("AmountPaid", "Amount_Paid") .Columns.Add("FeeType", "Fee Type") .Columns.Add("Class", "Class") .Columns.Add("Section", "Section") .Columns(0).Width = 60 .Columns(1).Width = 150 .Columns(2).Width = 100 .Columns(3).Width = 100 .Columns(4).Width = 80 .Columns(5).Width = 80 ' .AllowUserToAddRows = False .EditMode = DataGridViewEditMode.EditProgrammatically .ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter End With For Each dr As DataRow In DSet6.Rows Me.DataGridView1.Rows.Add() With Me.DataGridView1.Rows(Me.DataGridView1.Rows.Count - 1) .Cells("Regno").Value = dr("Regno") .Cells("SName").Value = dr("SName") .Cells("Amount_Paid") = dr("AmountPaid") .Cells("FeeType").Value = dr("FeeType") .Cells("Class").Value = dr("Class") .Cells("Section").Value = dr("Section") End With Next con.Close() 我的错误是AMOUNTPIAD归档不显示DatagridView .. Erros是:列''AmountPaid''不属于表。请帮助我My Error is AMOUNTPIAD Filed not show DatagridView.. Erros is : Column ''AmountPaid'' does not belong to table . Please Help Me推荐答案 Dim strSQL6 As String = "SELECT Regno, SName, SUM(AmountPaid) as TotalAmountPaid, FeeType, Class, Section FROM FeeTrans where... 发布此内容,将数据集的新列名绑定到网格中: Post this, bind the new column name of dataset to your grid as:.Cells("Amount_Paid") = dr("TotalAmountPaid") 参考: MSDN:DataColumnCollection.Add方法(字符串,类型) [ ^ ] 这篇关于DataGridView显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-29 15:56