I am using an ultragrid and inside i have values that i load into a datatable from a database. In my grid i group the rows into groups with OutlookGroupBy code. My rows in the grid are in two categories. The Priority 1 and 0. I want when the data are loaded the rows that are in priority 1 to get color red, and the others in priority 0 to be in normal color.
I use the ultragrid pro grammatically so i didnt use any of its features in the editor.
here is how i initialize my grid and how i load from database from another class:
Dim dt As DataTable = Nothing
Timer1.Enabled = True
UltraGrid1.DataSource = Nothing
Generic.openOrders(dt)
UltraGrid1.DataSource = dt
Dim band As Infragistics.Win.UltraWinGrid.UltraGridBand = UltraGrid1.DisplayLayout.Bands(0)
UltraGrid1.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy
band.SortedColumns.Add(band.Columns("PRIORITY"), True, True)
band.SortedColumns.Add(band.Columns("ORDERID"), False, True)
band.SortedColumns.Add(band.Columns("ORDERTIME"), False, True)
anyone has any idea of how can i change the row color into the priority 1 subrows??
You can try with this approach:
First you need to subscribe the event
InitializeRow, so add this by the designer or by code (eg. in Form_Load or before setting the DataSource of the grid)then, in the event, write code like this
Keep in mind that if you have set
CellAppearancethey will have precedence onRowAppearanceand, if you have many rows it is better to initialize anAppearanceobject, store it in thegrid.DisplayLayout.Appearancescollection and reuse the same object for every row involved.Moreover, always with the aim of improving the performance, to get the cell value it is better to use the
GetCellValuemethod of the row. This will avoid the creation of the a full Cell object just to retrieve its value. Things are a bit more complicated because you need anUltraGridColumnand not just the name of the column, but in the InitializeRow event, fired for each row, this is little price to pay.EDIT: The same code in VB.NET
Also, the use the UltraGridColumn class, you need to add at the start of file