Hi,
I have some data which I'm trying to display in the grid. It's essentially a set of locations and the rates to travel between them arranged in a matrix. So to see the rate from A to B, you locate the row with header 'A', and look along it until you come to the column with header 'B'. I have a datatable containing the results, with a row for each location, a first column containing the location names, then a column named after each location. The data display side of it is fine, but I'm struggling with the formatting of the grid. The rows and columns are completely dynamic, so I can't set their properties up at design time (can I?). What is the best way to handle this sort of thing?
One concrete example of something I'd like to achieve on this grid is the following. The diagonal row of A->A, B->B, etc should be coloured the same as the column headers. I've been able to make this work by hard coding a colour in to the relevant BackColour property, but this breaks if someone changes the appearance of the grid in the designer. I'd like to be able to select the same appearance as the headers for my diagonal cells. I tried variations on the following, but they don't work as the values I'm assigning from are all "Empty" - I assume this is because they've not been overriden and are inheriting from the underlying theme, but I'm not sure how to access that. Also, this would effect the whole column, but I want to be able to format individual cells, and I can't see how to do that :-(
Private Sub FormatGrid(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles grdRates.InitializeLayout
grdRates.DisplayLayout.Bands(0).Columns(0).CellAppearance = .DisplayLayout.Bands(0).Header.Appearance
End Sub
Kev
Thanks, that sounds like what I'm looking for
Hi Kev,
Okay, so basically you are looking for a way to get the resolved appearance of a column header. What you need to do is use the column.Header.ResolveAppearance method.
This is going to give you an AppearanceData object, though, not an Appearance. So if you want to set up an Appearance to apply to other opjects, you will probably need to copy the relevant settings to an Appearance object you create.