473,320 Members | 1,884 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,320 software developers and data experts.

Need help adding a new row to a DataGridView object

I've created a DataGridView through the UI, so all of my columns have
been added. My problem is that I can't quite figure out how to add a row to
it through code. I've tried calling CreateCells(), and this does work, but I
lose the column names for each row. When I go to reference the data in the
grid with dgv.Rows[0].Cells["type"], this fails with an error saying there
is no column with that name.
What do I need to do to be able to use the string column name instead of
the index?
Thanks,
Anthony
--
Product Availability Developer
Invensys Avantis - www.avantis.net
Jun 14 '06 #1
1 1424
"Anthony Hunter" <anthony.hunter@_NOSPAM_.invensys.com> wrote in message
news:O2****************@TK2MSFTNGP04.phx.gbl...
I've created a DataGridView through the UI, so all of my columns have
been added. My problem is that I can't quite figure out how to add a row
to it through code. I've tried calling CreateCells(), and this does work,
but I lose the column names for each row. When I go to reference the data
in the grid with dgv.Rows[0].Cells["type"], this fails with an error
saying there is no column with that name.
What do I need to do to be able to use the string column name instead
of the index?


Maybe I'm missing something, but can't you just set the RowCount property?

Chris Jobson
Jun 14 '06 #2

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

Similar topics

0
by: wackyphill | last post by:
Anyone seen this? Know if its a bug? I'm pretty sure it is. I have a DataGridView control in a tab control who's datasource is a table in a dataset. In certain situations when I add a row to the...
6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
2
by: bob | last post by:
After adding a new row (programmatically) to a table/view that is being displayed in the DataGridView control, the new row appears in the DataGridView grid. Now, how do I select that new row? If...
7
by: BillE | last post by:
What is the best way to add data using a DataGridView in a multi-tier application (data entry is handled in a data access layer using stored procedures)? Thanks Bill
8
by: Izzy | last post by:
I'm writting an app that has two DataGridViews, in the first grid I load a list on companies. Between the 2 grids are two buttons with arrows, one points to the right the other to the left. When...
0
by: jeastman - Hotmail | last post by:
Hello world Excuse, not to be written English and it helps me with a translator. I am new programming in C#. I made a control inheriting the DataGridView to be able to add controls done by...
0
by: Andrus | last post by:
I tried to use modeless picklist for DataGridView custom ComboBoxColumn without success. Steps to reproduce issue: 1. Run code 2. Enter some character 3. Press Tab Observed:
3
by: jehugaleahsa | last post by:
Hello: I am binding a DataGridView with a BindingList<T>, where T is a custom business object that implements INotifyPropertyChanged. When you bind a DataGridView to a DataTable, it has this...
1
by: gobblegob | last post by:
Hello Folks, I am searching a XML file for <Asset_Number> and then adding all children to DataGridView1, i can search but i dont know how to add item to the DataGridView Also my datagridview...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.