传递与传播在函数上返回datagrid [英] pass & return datagrid on a function

查看:79
本文介绍了传递与传播在函数上返回datagrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我已经使用了这段代码



Hi I''ve used this code for so long

Public Sub ShowDataTable(Optional ByVal field As String = "*", Optional ByVal range As String = Nothing)
    SQL = "CALL Phonedb.MyPhonebook('" & field & "','" & range & "')"
    Dim ds As New DataSet
    Using condb As New MySqlConnection(con)
        condb.Open()
        Using cmd As MySqlCommand = condb.CreateCommand
            cmd.CommandText = SQL
            Using sqlAdapter As New MySqlDataAdapter(SQL, condb)
                sqlAdapter.Fill(ds)
            End Using
        End Using
        condb.Close()
    End Using
    DTG.DataSource = ds.Tables(0)
End Sub



我不想尝试使它成为一个Class / sub

我的任务是如何在一个函数/ sub上传递datagridview并返回它?



添加Sub上的参数是我的问题



Public Sub ShowDataTable(ByVal STRD As String,ByVal conStr As String)

推荐答案

有一个名为DataGrid的类,您可以将其作为一种类型发送给您作为参数的方法,也可以返回相同的类。我对VB并不熟悉,但无论如何我在C#中给出了示例方法,这显然可以帮助你在VB中实现相同的方法。



There is a class called DataGrid, which you can use as a type to send in you method as a parameter and also you can return the same. I''m not much familiar with the VB but anyhow I have given example method in C#, which would obviously can help u to implement the same in VB.

public DataGrid SomeMethod(DataGrid dg)
        {
            DataGrid grid = new DataGrid();
            grid.AllowPaging = true;
            return grid;
        }


这篇关于传递与传播在函数上返回datagrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆