Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add row data manually by datagridview

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "datagridview how to add row data manually", so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "datagridview how to add row data manually" article.

Datagridview manually add row data

I am doing the software model interface, through the function button to trigger the display of datagridview, for convenience, need some data, just write dead data on it, therefore, do not need to connect the data table, just add rows on it.

The code is as follows:

Int index = this.dataGridView1.Rows.Add (); this.dataGridView1.Rows [index] .cells [0] .value = "1"; this.dataGridView1.Rows [index] .cells [1] .value = "11"; this.dataGridView1.Rows.cells [2] .value = "1111"; this.dataGridView1.Rows[ index] .cells [3] .value = "11111" This.dataGridView1.Rows [index] .cells [4] .value = "111111"; this.dataGridView1.Rows[ index] .cells [5] .value = "1111111"; this.dataGridView1.Rows [index] .cells [6] .value = "*-*"; several ways for datagridview to add rows

1. Data binding

DataGridView1.AutoGenerateColumns = true;dataGridView1.DataSource = customersDataSet

This automatically generates row data for the corresponding data. If the column is not automatically generated, add the column manually and set the data source property name (DataPropertyName) of the column to the property name of the corresponding data class.

2. Add manually

SongsDataGridView.ColumnCount = 5;. SongsDataGridView.Columns [0] .Name = "Release Date";.... string [] row0 = {"11 White Album 22 1968", "29", "Revolution 9", "Beatles", "The Beatles [White Album]"}; songsDataGridView.Rows.Add (row0)

In addition, you can access row cells in this way

This.dataGridView1.Rows [1] .cells [0] .value = "new value"; / / or the equivalent this.dataGridView1 [0,1] .value = "new value". The above is about "how to manually add row data in datagridview". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report