473,795 Members | 2,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagridview: Copy row to array

My datagridview has columns with text AND integers.

Please can someone help me with the code necessary to copy an entire
selected row of mixed content cells to an array ?

Thanks very much
Aug 18 '06 #1
3 21798
Silvester,

System.Collecti ons.ArrayList array = new System.Collecti ons.ArrayList() ;
for (int i = 0; i < this.dataGridVi ew1.Columns.Cou nt; i++)
array.Add(this. dataGridView1[i, 0].Value); /// Make sure the second
value is a valid row

Regards,
John

"Silvester" <no***@none.com wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
My datagridview has columns with text AND integers.

Please can someone help me with the code necessary to copy an entire
selected row of mixed content cells to an array ?

Thanks very much

Aug 18 '06 #2
Each DataGridViewRow has a DataBoundItem object property that represents the
underlying datasource for that row. So for example, if it was a DataRow from
a DataTable, that DataRow would sport a convenient ItemArray property.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Silvester" wrote:
My datagridview has columns with text AND integers.

Please can someone help me with the code necessary to copy an entire
selected row of mixed content cells to an array ?

Thanks very much
Aug 18 '06 #3
John / Peter,

Thank you for your replies. Will this code below pick up cell values for the
selected row ? System.Collecti ons.ArrayList array = new
System.Collecti ons.ArrayList() ;
for (int i = 0; i < this.dataGridVi ew1.Columns.Cou nt; i++)
array.Add(this. dataGridView1[i, 0].Value); /// Make sure the second
value is a valid row

My source DGV is indeed databound.
Peter, please can you show me a code sample for your method ?
Aug 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1831
by: Rob | last post by:
Dear All, I am having a few issues with DataGridViews. Here is what I have. In a windows form I have added a DataGridView. My data is stored in an array of instances of a class with several properties. Then I simply set the data source property of the DataGridView to that array. The data is displayed but there are a few issues: 1) The container is not the same size as the actual area occupied by the data that is visualized. For...
3
32280
by: Rich | last post by:
Hello, I am populating a datagridview from a datatable and filtering the number of rows with a dataview object. Is there a way to retrieve the rows displayed by the datagridview into a separate datatable without having to loop through each column in the datagridview? Or is there a way to retrieve the rows from the original datatable filtered by the dataview into a separate table? I only want to copy the rows from the main table that...
0
1958
by: bappelsin | last post by:
Hello, I have a problem with the datagridview. I have a view with around 25 different columns. To make life easier for the users I have implemented a popup dialog where the user can select which columns that should be displayed and in which order the columns are shown. After user has selected the visible columns and the order he presses ok. The grid is first cleared from rows, then I add all visible columns and then all hidden. Grid is...
0
2002
by: MathewJose | last post by:
Hi, I have a DatagridView in windows form.It has got a column which has some names that are populated from master table in database.Now i need to copy a set of data against these names. I tried to populate data to the first column from database and then tried to copy excel sheet data against each name but some exceptions are coming.It says "cannot programmaticaly add rows while using data bind". This is the code that i used for...
0
1173
by: Chris | last post by:
I have a DataGridView in a form that will display the information from various DataTables in my DataSet. The user is provided a list of tables and when they select a table name, the DataGridView displays the appropriate DataTable. When a user changes some of the settings in my program, I sometimes have to recreate some of the DataTables, however, the DataGridView will still somehow display the original DataTable even if the DataGridView...
1
5242
by: The Tarm | last post by:
Hi everyone, I found resources on the web to do a copy on a datagridview control but i havent found any on pasting back to the control. I m trying to figure out how to do a shallow copy on a datagrid row. if (c is DataGridView) { DataGridView d = (DataGridView)c;
0
2071
nirmalsingh
by: nirmalsingh | last post by:
hi all, i am using datatable and dataset to assign data into datagridview. now i want to print data of datagridview contents. i used a method to copy datagridview content in a clipboard and to paste it in a print document. it is working fine but data is unaligned, so i think that if i apply borderstyle to datagridview and then copy to clipboard, but it doesnt work fine. anybody tell me the solution to resolve this. my another question is,...
1
1611
nev
by: nev | last post by:
Happy Easter to all! I have a problem with a datagridview. I placed code in a button click event as follows: dim dtt as datatable = dataset.employees.copy dtt.DefaultView.RowFilter = "='" & Me.LastNameTextBox.Text & "'" Me.DataGridView.DataSource = "" Me.DataGridView.DataSource = dtt
3
27969
by: bharathi228 | last post by:
hi, how to assign a array as datasource to datagridview in vb.net. my problem is iam having an array with 60 values
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.