473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Fill DataGridView into another DatagridView

54
Please help me out!
Am using VB.NET 2008 and I have two DataGridviews namely DataGridview1 and DataGridView2.. Now, I have 4 columns which are check1, Name, Address and Age.
My headache now is, I want after a user checks/selects rows from DataGridView1, then those rows should be filled in DataGridView2 on a click of a button.
Is that really possible? Help me out gurus.

Thanks in advance.

ben.
Mar 21 '09 #1
6 14154
MrMancunian
569 Expert 512MB
Sure it is possible. Create a Sub that checks the value of the check-field in the datagridview1. You can use a For-Next-loop to go though your datagridview. Something like this:

Expand|Select|Wrap|Line Numbers
  1. Dim a as Integer
  2. For a = 0 to Datatgridview1.Rows.Count - 1
  3.   If Datagridview1.Rows(a).Cells("Check1").Checked = True then
  4.     Datagridview2.Rows.Add(Datagridview1.Rows(a).Cells("Check1").Value, Datagridview1.Rows(a).Cells("Name").Value, Datagridview1.Rows(a).Cells("Address").Value, Datagridview1.Rows(a).Cells("Age").Value)
  5.   End If
  6. Next
  7.  
I didn't test this, so there are probably some flaws, but the technique should be something like this :-)
Mar 21 '09 #2
Benniit
54
Hi, the code u sent could be helpful, but this line was underlined and it pops up a tooltip that reads checked is not a member of Systems.Windows.DataGridView

If DataGridView1.Rows(a).Cells("Check1").Checked = True Then

if u can please fix that bug for me.

ben
Mar 23 '09 #3
aryanbs
42
DataGridView1.Rows(a).Cells("Check1").Value= True
Mar 23 '09 #4
Benniit
54
Thanx and God bless u, it worked. Anytime i click the fill button, the data in DataGridView2 gets duplicated. How can I make it fill the grid once. I used the exit for, to exit the loop after filling the DataGridView2 once, but that also did not work. Any suggestions?
Ben
Mar 24 '09 #5
aryanbs
42
Just clear DataGridView2 before loop.

DataGridView2.Rows.Clear()
Mar 24 '09 #6
Benniit
54
Thank you a lot!
It works. god bless you all.

Ben
Mar 25 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: euphorica | last post by:
I am making an inventory database. I have a field InventoryNumber where I put a specific code. The code always starts with a particular letter. I would like to fill in another field with...
3
by: Art | last post by:
Hi, Forgive me for posting this message in 2 groups -- it appears that the Data Access group isn't very active, so I'm posting again here: I have a DataTable that I want to fill using a...
2
by: Bill Nguyen | last post by:
I'm learning DatagridView. How do I define a checkbox column type? Thanks Bill
0
by: carlostol | last post by:
Hello, How can i copy a selected DataGridViewRow who has been clicked to another DataGridView Control in a dinamyc way? I have this code on a button_click event: DataGridViewRow r =...
0
by: vbt | last post by:
I am new to using the DataGridView and I have read most everything I can find on this subject. But obviously I am not see the hole picture. I am trying to update a data base using the...
2
by: alagan | last post by:
Hai,, I am mathiyalagan. Working in a small s/w in my home town.. We are doing some database related windows applications.. Actually we had problem with the datagridview that is we had...
2
by: harikap | last post by:
hi, i have added checkbox column to windowsdatagriview in vb.net 2005 & if i select those values, how can i get them into another datagridview plz help me out....
0
by: Paul | last post by:
Hi, I'm a tables one to many. I want to do the DataGridView of a particular row, to expand into another DataGridView, but in the row of the first DataGridView Any idea? Gracias
0
by: Flupke | last post by:
Hello All, In a VB2005 Application, I want at a certain point clear the contents of a datagridview, but maintain the columnheaders on the datagrid itself so that it is obvious that the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.