TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anu
NA
1
0
Help regarding cell click event in datagridview
Sep 28 2007 8:48 AM
hi all,
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?
Reply
Answers (
0
)
how do i protect my application folder
inerith-virtual - override