将文本附加到数据表中的现有行

发布于 2024-09-13 01:56:21 字数 1407 浏览 2 评论 0原文

我正在尝试在 vb.net 中制作日历,但遇到了这个问题。我想将一些文本附加到现有数据表行中。当我观察调试器时,它说:“为了评估索引属性,该属性必须经过限定,并且参数必须由用户显式提供。”。

 Dim aantalRijen As Integer = 1

    For x = 0 To 6
        Dim dttopdrachten As New DataTable
        dttopdrachten = opdrachtendao.getOpdrachtenByDate(Today.AddDays(x))
        If dttopdrachten.Rows.Count > aantalRijen Then
            aantalRijen = dttopdrachten.Rows.Count
        End If
    Next

    For z = 0 To aantalRijen - 1

        Dim r As DataRow
        r = dttAgenda.NewRow()
        dttAgenda.Rows.InsertAt(r, z)

    Next

    For i = 0 To 6

        Dim aantalItems As Integer = 0
        Dim dttopdrachten As New DataTable
        dttopdrachten = opdrachtendao.getOpdrachtenByDate(Today.AddDays(i))
        aantalItems = dttopdrachten.Rows.Count

        For j = 0 To aantalItems - 1

            Dim info As String = dttopdrachten.Rows(j).Item(0).ToString & vbCrLf & dttopdrachten.Rows(j).Item(2).ToString & vbCrLf & dttopdrachten.Rows(j).Item(3).ToString & vbCrLf & dttopdrachten.Rows(j).Item(4).ToString & vbCrLf & dttopdrachten.Rows(j).Item(5).ToString & vbCrLf & dttopdrachten.Rows(j).Item(6).ToString
            dttAgenda.Rows(j).Item(i) = info

        Next

    Next

    dgvAgenda.DataSource = dttAgenda

在上面的代码中,我首先计算必须制作多少行。然后,我将行数添加到数据表中(之前添加了列)。直到这里它才起作用,但是当我继续调试时,我收到了错误。我尝试过谷歌搜索,但到目前为止没有任何帮助。

I'm trying to make a calendar in vb.net and I have come across this problem. I want to append some text into an existing datatable row. When I watch my debugger it says:"In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.".

 Dim aantalRijen As Integer = 1

    For x = 0 To 6
        Dim dttopdrachten As New DataTable
        dttopdrachten = opdrachtendao.getOpdrachtenByDate(Today.AddDays(x))
        If dttopdrachten.Rows.Count > aantalRijen Then
            aantalRijen = dttopdrachten.Rows.Count
        End If
    Next

    For z = 0 To aantalRijen - 1

        Dim r As DataRow
        r = dttAgenda.NewRow()
        dttAgenda.Rows.InsertAt(r, z)

    Next

    For i = 0 To 6

        Dim aantalItems As Integer = 0
        Dim dttopdrachten As New DataTable
        dttopdrachten = opdrachtendao.getOpdrachtenByDate(Today.AddDays(i))
        aantalItems = dttopdrachten.Rows.Count

        For j = 0 To aantalItems - 1

            Dim info As String = dttopdrachten.Rows(j).Item(0).ToString & vbCrLf & dttopdrachten.Rows(j).Item(2).ToString & vbCrLf & dttopdrachten.Rows(j).Item(3).ToString & vbCrLf & dttopdrachten.Rows(j).Item(4).ToString & vbCrLf & dttopdrachten.Rows(j).Item(5).ToString & vbCrLf & dttopdrachten.Rows(j).Item(6).ToString
            dttAgenda.Rows(j).Item(i) = info

        Next

    Next

    dgvAgenda.DataSource = dttAgenda

In the code above, I first count how many rows I have to make. Afterwards I add the amount of rows to the datatable (columns are added before). Until here it works, but then when I keep debugging I get the error. I tried googling but nothing could help me so far.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瞄了个咪的 2024-09-20 01:56:21

看起来问题已经解决了,没有做任何改变。所以如果有人想制作日历。这是解决方案;)

Seem problem has been solved without changing anything. So if someone want to make a calendar. Here's the solution ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文