DataGrid Cell Problem

L

Larry Dodd

I want to be able to change some properties of certain cells on the
datagrid. For instance, let's say the datagrid has 10 rows and 5 columns. I
want the first five rows to be normal but on the 6th through 10th row. I was
the first two columns to have a background in the cell that is gray.

Even better would be to have the first two columns on the 6th through 10th
row to span two columns. I have included a small example below. Any help on
either of these problems would be appreciated.
 
L

Larry Dodd

This is great information but how would i do this based and a certain row.
For instance, what if I wanted Row 6 Cell 0 formatted differently from other
cells?

Alvin Bruney said:
nothing to it. you would need to put the appropriate code in the
itemcreated, or itemdatabound event handler. Every time a row is created, it
fires off an event. trap the above event and use the datagrideventargs e to
customize.
something like this will work
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem || e.Item.ItemType ==
ListItemType.SelectedItem)

{

//catch the first row and span column zero over the next three columns

e.Item.Cells[0].RowSpan = 4

}

Larry Dodd said:
I want to be able to change some properties of certain cells on the
datagrid. For instance, let's say the datagrid has 10 rows and 5
columns.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top