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

Help regarding cell click event in datagridview

hi all,

i am new to this forum. i am using a windows application using C#.

I am using a datagridview to display contents of a xml file. say i have a xml file like this.

<xml version="1.0" encoding="UTF-8">
<maincategory>
<cat1>
<title>Category1</title>
<link>http://www.w3schools.com</link>
<description><img src="http://static.ibnlive.com/pix/sitepix/09_2007/flames_ramsetu90.jpg" >some description</description>
</cat1>
<cat2>
<title>Category2</title>
<link>http://www.ibnlive.com</link>
<description><img src="http://static.ibnlive.com/pix/sitepix/09_2007/rahul_gandhi_white90.jpg"
>some description</description>
</cat2>
</maincategory>

initially i display only the title of the category in the grid.
when the cell is clicked, i display title as well as description. when i click the cell again, only the title should be displayed.
i have managed to do this part.

the following code is for the first time click
if (cell_click_flag[rindex]==false)
{
TextAndImageCell cell = (TextAndImageCell)datagridview1.CurrentCell;
cell.Value = "";
cell.Image = Image.FromFile(Application.StartupPath + "//spacer.gif");
datagridview1.CurrentCell.Value = datagridview1.Rows[rindex].Cells["Description"].Value;
cell.Style.Alignment = DataGridViewContentAlignment.TopLeft;
cell_click_flag[rindex] = true; datagridview1.AutoResizeRow(rindex, DataGridViewAutoSizeRowMode.AllCells);
}
else if (cell_click_flag[rindex] == true)
{
//for the second time click
TextAndImageCell cell = (TextAndImageCell)dat.CurrentCell;
cell.Value = "";
cell.Image = Image.FromFile(Application.StartupPath + "//spacer.gif");
datagridview1.CurrentCell.Value = datagridview1.Rows[rindex].Cells["temp_title"].Value;
cell.Style.Alignment = DataGridViewContentAlignment.TopLeft;
cell_click_flag[rindex] = false; datagridview1.AutoResizeRow(rindex, DataGridViewAutoSizeRowMode.AllCells);
}

but when i again click the cell, only the title is displayed and not the description.i tried debugging, the value contains both title and description but only title is displayed.

I could not understand the problem.

Can anybody suggest me with some ideas?

Thanks in advance
Regards

Anuradha
Sep 28 '07 #1
0 1488

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

Similar topics

3
by: Rich | last post by:
Hello, If I want to update data displayed in a datagrideview/datagridview cell, how can I determine what cell I am updating? I am looking at the click event below, for example. Can I get...
1
by: Riley | last post by:
Need some help. I am using datagridview in 2005 with C#. I am calling a web service and filling the datagridview with the data returned. This all works fine. Next step is to take a value from one...
2
by: Karl | last post by:
Hi all, I'm reasonably new to csharp so you have to forgive me asking what may be a stupid question... As I said, I'm new to CSharp but in VB I was able to click anywhere on a DataGridView...
1
by: Asif Mohammed | last post by:
Hello, I have a databound datagridview, its allowed to add,remove and edit I type a value in (in new row), it uses e.cancel = true to invalidate the cell .. and does not let focus go away, but...
1
by: seanmle | last post by:
I want to build a windows application that has a datagrid filled with data. When a person modifies information on a single cell, it updates the database without the user having to click on a save...
2
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, When clicking on the top left corner of a datagridview - then entire contents of the datagridview is selected. When clicking on that cell - what event gets triggered/fired? I tried...
0
by: =?Utf-8?B?UmljaA==?= | last post by:
In a datagridview, the first column header cell is columnHeader(0), which is immediately to the right of the Top Left Corner Select All cell. And the first RowHeader cell is RowHeaderCell(0) which...
1
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns...
12
by: cj | last post by:
When viewing a datatable in a datagridview one of the columns in it is a "note" field which can be quite long. I would like to have the note field of the currently selected row of the datagrid...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.