By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,880 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,880 IT Pros & Developers. It's quick & easy.

Help regarding cell click event in datagridview

P: 1
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">
<description><img src="" >some description</description>
<description><img src=""
>some description</description>

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

Sep 28 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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