473,396 Members | 1,775 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.

DataGrid issue

Hi all.
In VB.Net I used the Item method in order to get a value from a DataGrid.
Now I'm working with C# and I can't use this method.

how the heck do you do that in C#????

TIA,
Sebastián
Nov 16 '05 #1
4 1020
Sebastián,

This is an indexer in C#. You simply have to refer to the row,column of the
cell. I have posted a sample from the MSDN below.

I hope this helps.
----------------------------
//link to the MSDN
http://msdn.microsoft.com/library/de...asp?frame=true

private void PrintCellValues(DataGrid myGrid){
int iRow;
int iCol;
DataTable myTable;
// Assumes the DataGrid is bound to a DataTable.
myTable = (DataTable) dataGrid1.DataSource;
for(iRow = 0;iRow < myTable.Rows.Count ;iRow++) {
for(iCol = 0;iCol < myTable.Columns.Count ;iCol++) {
Console.WriteLine(myGrid[iRow, iCol]);
}
}
}

Nov 16 '05 #2
If you have specified a DataKeyField in you binding code, then you can do
something like:

int test = Convert.ToInt32(DataGrid1.DataKeys[e.Item.ItemIndex]);

"Sebastián::PJ" <NO***********@poderjudicial.gub.uy> wrote in message
news:OJ**************@TK2MSFTNGP15.phx.gbl...
Hi all.
In VB.Net I used the Item method in order to get a value from a DataGrid.
Now I'm working with C# and I can't use this method.

how the heck do you do that in C#????

TIA,
Sebastián

Nov 16 '05 #3
Hi,

Post the VB code and it will translated
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Sebastián::PJ" <NO***********@poderjudicial.gub.uy> wrote in message
news:OJ**************@TK2MSFTNGP15.phx.gbl...
Hi all.
In VB.Net I used the Item method in order to get a value from a DataGrid.
Now I'm working with C# and I can't use this method.

how the heck do you do that in C#????

TIA,
Sebastián

Nov 16 '05 #4
Thanx guys...

"Brian Brown" <Br********@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
Sebastián,

This is an indexer in C#. You simply have to refer to the row,column of the cell. I have posted a sample from the MSDN below.

I hope this helps.
----------------------------
//link to the MSDN
http://msdn.microsoft.com/library/de...asp?frame=true
private void PrintCellValues(DataGrid myGrid){
int iRow;
int iCol;
DataTable myTable;
// Assumes the DataGrid is bound to a DataTable.
myTable = (DataTable) dataGrid1.DataSource;
for(iRow = 0;iRow < myTable.Rows.Count ;iRow++) {
for(iCol = 0;iCol < myTable.Columns.Count ;iCol++) {
Console.WriteLine(myGrid[iRow, iCol]);
}
}
}

Nov 16 '05 #5

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

Similar topics

11
by: Junkguy | last post by:
I need some help programmatically causing a row in a DataGrid to "flush" its contents to its bound data (in Visual Studio 6 using Windows Forms with C#). My issue is I want to send an update to...
3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
7
by: Dave | last post by:
Are there any add-on products or samples available that can do the following in an vb.net datagrid I want to compare 2 rows in a datagrid - one row from one database and another row for another...
7
by: Earl | last post by:
Any known fixes for the wacky right-alignment bug in the WinForms datagrid (VS2003)? I've tried Ken's workaround...
3
by: Brian Tkatch | last post by:
I have a form with two DataGrids, which are kept in sync manually via Stored PROCEDURE calls. That is, when a record is selected on the first grid, a stored PROCEDURE is CALLed to Fill() the next...
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?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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...
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.