473,715 Members | 6,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I get the data in a given Datagrid row or cell ?


Hi,

I would like to get the Data of a given cell in the datagrid something like :

MyStringVar = MyDataGrid.Tabl eStyles[0].Cell[X,Y].ToString();

But I can't find any way to read the data of a given cell, or row.....

Any Idea ?

Thanks for help,

Steph.

_______________ _______________ _______________ _______________ __

Stephane Orban
IT Manager
EOLE-UNICLAM
EMail : in**********@un iclam.com
Web : www.uniclam.com
Tel : +32 (0) 2 227 54 98
Fax : +32(0) 2 218 74 60

Nov 16 '05 #1
2 1263
Hi there...

You could use the CurrencyManager Class as shown below (asigning value to label1.Text) or
using datagrid's CurrentCell property (label2.Text).
private void dataGrid1_Curre ntCellChanged(o bject sender, System.EventArg s e) {
CurrencyManager cm = (CurrencyManage r) dataGrid1.Bindi ngContext[dataSet11.Table s[0]];
label1.Text = cm.Position > -1 ? ((DataRowView) cm.Current).Row[dataGrid1.Curre ntCell.ColumnNu mber].ToString() :
string.Empty;

label2.Text = dataSet11.Table s[0].Rows[dataGrid1.Curre ntCell.RowNumbe r]
[dataGrid1.Curre ntCell.ColumnNu mber].ToString();

}

Regards,
--
Angel J. Hernández M.
MCSD


"Steph." <st***@nomail.c om> escribió en el mensaje news:O2******** ******@TK2MSFTN GP09.phx.gbl...

Hi,

I would like to get the Data of a given cell in the datagrid something like :

MyStringVar = MyDataGrid.Tabl eStyles[0].Cell[X,Y].ToString();

But I can't find any way to read the data of a given cell, or row.....

Any Idea ?

Thanks for help,

Steph.

_______________ _______________ _______________ _______________ __

Stephane Orban
IT Manager
EOLE-UNICLAM
EMail : in**********@un iclam.com
Web : www.uniclam.com
Tel : +32 (0) 2 227 54 98
Fax : +32(0) 2 218 74 60

Nov 16 '05 #2
Hi Steph,

string var = MyDataGrid[row, column].ToString();
string var = MyDataGrid[MyDataGridCell].ToString();

--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3

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

Similar topics

4
4266
by: TT (Tom Tempelaere) | last post by:
Hi, Suppose there is a DataGrid on a form bound to a DataTable. When a user is editing a cell without leaving the cell, and then closes the form, the value is not updated to the underlying data source. How can I accomplish this? Thanks, --
1
1601
by: Raul Cortes | last post by:
Hi. I am using a windowsform datagrid to modify a table. The DataSet seems to be filled fined. The DataTable seems to be ok. I am not using 'read only' anywhere. The DataSource seems to be well asigned. The DataMenber assigned to the table. One column of the DataSet is decimal type.
1
1840
by: Blake Versiga | last post by:
When editing a datagrid (C#) I need to know if the user changed the value of cell AND what the previous value was. Is this possible? If so how do I get the previous value or at least if the cell has changed? TIA Blake
2
1980
by: Nedu N | last post by:
Hi, I want to display the XML tags (for the the XML tags is the data that is stored in a table) on the datagrid using the datasets. But since the data itself is the XML tag it doesn't appera on the datagrid since it tries to parse the data before it displays. Using Server.HtmlEncode, i was able to display the right content on the datagrid for each and every colum using Template column. But i don't want to use any template columns...
3
2049
by: bbernieb | last post by:
Hi, All, Is it possible to access a variable inside of a data binding, without the variable being out of scope? (Note: On the DataBinder line, I get an error message that says "Name 'i' is not declared". The data bind is for a DataList.)
9
1540
by: Sean | last post by:
I am using a datagrid to display some data. I notice when I click in a cell where the data is longer than the cell width, it truncates the end of the data off. For example: The data is: This is sample data Column only has room for:
1
1204
by: adi busu via DotNetMonster.com | last post by:
Hi I need an event that could help me to update the datagrid current cell data every time it is changed. i tried with currentCellChanged but when i leave the datagrid this event does not occure so the last selected cell is not updated. i also have some comboBoxColumns so it's very tricky (these are updated in the combobox.comboSelectedIndexChanged event) Does anyone have any ideea? thank you -- Message posted via...
5
3152
by: Antonio | last post by:
Hello, everyone. Is there a way to not display a certain value in a datagrid cell? I have a datagrid for subscriptions and ebooks and if there isn't an e-book listed, the value from the database (SQL) is "Null/No Set Dummy Row". Is there a way I can suppress that data in the datagrid? Thanks,
6
2944
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1) Constraint pk_table1 Primary Key,
0
8823
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9104
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
9047
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...
1
6646
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
4477
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
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2119
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.