search
HomeCommon ProblemHow datagridview displays data
How datagridview displays dataJan 12, 2021 pm 01:56 PM
datagridview

How to display data in datagridview: 1. Find the "DataSource" property in the property window and select "Dataset"; 2. Select "Data Connection" and click "New Connection"; 3. Join the link dialog Change the data source in the box; 4. Select the database in the data field, and then click "OK".

How datagridview displays data

The operating environment of this article: Windows 7 system, DataGridView control, Dell G3 computer.

Methods for datagridview to display data:

The first method is to set the data through properties

First find the DataSource property in the property window , click the drop-down box. This is the first time to use it. If you have added it before, click to add the data source

How datagridview displays data

Select the data type, next step, select the data set, next step

How datagridview displays data

Select the data connection and click New Connection

How datagridview displays data

Change the data source (the SQL Server database I use) in the Join Link dialog box and click the drop-down Select the server name in the box (the dot defaults to your own server). Then select the database under Connect to Data. If the test link passes, click OK. At this time, you return to the data configuration wizard. Click Next to select the table you want to display in the database.

How datagridview displays data

After the addition is completed, the execution window data will be displayed

How datagridview displays data

Another method is to pass Write code to load data

<span style="font-family:KaiTi_GB2312;font-size:18px;">    &#39;定义一个函数查找规定日期内的收取金额
    Public Function check_money(ByVal tstRecharge As Model.RechargeModel) As DataTable
        Dim strSQL As String = "select * from Recharge_info where rechargeDateTime between @startdatetime and @enddatetime"
        Dim params As SqlParameter() = {New SqlParameter("@startdatetime", tstRecharge.start_datetime), New SqlParameter("@enddatetime", tstRecharge.end_datetime)}
        Dim helper As New SqlHelper
        Dim dat = helper.GetDataTable(strSQL, CommandType.Text, params) &#39;调用sqlhelper
        Return dat &#39;返回查到的数据表
    End Function</span>
<span style="font-family:KaiTi_GB2312;font-size:18px;"> Dim db As New DAL.CkeckMoneyDAL &#39;定义一个D层对象,用来调用D层函数
    &#39;定义一个函数,用来检查D层查找金额返回的数据
    Public Function check_return(model As Model.RechargeModel) As DataTable
        Dim dat = db.check_money(model)
        If dat.Rows.Count = 0 Then &#39;检查D层返回的数据表中是否有数据
            Return Nothing
        Else
            Return dat
        End If
    End Function</span>
<span style="font-family:KaiTi_GB2312;font-size:18px;"> Dim thisRecharge As New Model.RechargeModel &#39;定义一个实体层对象,用来接收起止时间
        thisRecharge.start_datetime = DateTimePicker1.Text
        thisRecharge.end_datetime = DateTimePicker2.Text
        Dim ub As New BLL.CheckMoneyBLL &#39;定义一个B层对象,用来调用B层函数
        If ub.check_return(thisRecharge) Is Nothing Then
            MsgBox("该时间段内没有记录,请又一次设置时间段!", MsgBoxStyle.Exclamation, vbOKOnly)
        Else
            dvwTitles.DataSource = ub.check_return(thisRecharge) &#39;把查到的数据传给datagridview
        End If</span>

Display results:

How datagridview displays data

Both methods have their own advantages and disadvantages. We need to choose according to our actual situation. . When we only need to display the data of the entire table or there is not much data in the table, the first method is the easiest and does not require writing any code. Suppose we want the data to be displayed selectively. For example, the picture above only displays the data from June 18th to June 20th. Although it seems cumbersome to write code, the display results are clear at a glance, which prevents us from searching for a large amount of data. The data we need greatly improves efficiency.

Related free learning recommendations: php programming (video)

The above is the detailed content of How datagridview displays data. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
deepseek web version official entrancedeepseek web version official entranceMar 12, 2025 pm 01:42 PM

The domestic AI dark horse DeepSeek has risen strongly, shocking the global AI industry! This Chinese artificial intelligence company, which has only been established for a year and a half, has won wide praise from global users for its free and open source mockups, DeepSeek-V3 and DeepSeek-R1. DeepSeek-R1 is now fully launched, with performance comparable to the official version of OpenAIo1! You can experience its powerful functions on the web page, APP and API interface. Download method: Supports iOS and Android systems, users can download it through the app store; the web version has also been officially opened! DeepSeek web version official entrance: ht

In-depth search deepseek official website entranceIn-depth search deepseek official website entranceMar 12, 2025 pm 01:33 PM

At the beginning of 2025, domestic AI "deepseek" made a stunning debut! This free and open source AI model has a performance comparable to the official version of OpenAI's o1, and has been fully launched on the web side, APP and API, supporting multi-terminal use of iOS, Android and web versions. In-depth search of deepseek official website and usage guide: official website address: https://www.deepseek.com/Using steps for web version: Click the link above to enter deepseek official website. Click the "Start Conversation" button on the homepage. For the first use, you need to log in with your mobile phone verification code. After logging in, you can enter the dialogue interface. deepseek is powerful, can write code, read file, and create code

How to solve the problem of busy servers for deepseekHow to solve the problem of busy servers for deepseekMar 12, 2025 pm 01:39 PM

DeepSeek: How to deal with the popular AI that is congested with servers? As a hot AI in 2025, DeepSeek is free and open source and has a performance comparable to the official version of OpenAIo1, which shows its popularity. However, high concurrency also brings the problem of server busyness. This article will analyze the reasons and provide coping strategies. DeepSeek web version entrance: https://www.deepseek.com/DeepSeek server busy reason: High concurrent access: DeepSeek's free and powerful features attract a large number of users to use at the same time, resulting in excessive server load. Cyber ​​Attack: It is reported that DeepSeek has an impact on the US financial industry.

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.