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?

Thanks in advance

Regards

Exelio

thanks guys.i solved it myself.

for anybody's reference, i used beginedit(true) and endedit() methods within the cell click event to update the cell valyes.

Thanks again

Regards

Exelio

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.