on 09-21-2015 8:15 AM
Hi, everybody
We are working on a SDK add-on, and are using Visual Basic.NET.
We have generated a grid which derives its data from a Query.
We want to colour the rows (in a special way) to facilitate reading the data on the grid.
Please see the picture.
Anybody has an idea how to implement this kind of colour banding?
Thanks
Leon Lai & Team
Hi Leon Lai,
You could simply loop through the rows and assign a new color to the row each time IT ref changes.
However there are two questions you need to ask yourself:
Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Johan
Thanks a lot for your reply.
I have successfully implemented simple alternating colour banding in previous projects (sort of Red - Blue - Red - Blue - etc) based on row number only. If row number is even, then red. If row number is odd, then blue.
But this problem is more complex and I have no idea how to solve it.
To answer your questions:
1. User will not be required to do any sorting. Sorting has already been done by my query.
2. I prefer to use 2 colours only (say red and blue). Too many colours can be ugly.
Hope this can help.
Best Regards,
Leon
Hi Leon,
Roughly :
Dim LastColour as String = Red
Dim LastITRef as String = ""
For i as integer = 0 to oGrid.Rows.Count -1
Dim CurrentRowITRef as String = oGrid.DataTable.Rows.GetValue("col", oGrid.GetDataTableRowIndex(i)).ToString.Trim
If LastITRef = CurrentRowITRef then
'Set Current Row to LastColur.
Else
If LastColur = Red Then
'Your code to set Current Row as Blue here
LastColour = 'Blue'
Else
'Your code to set Current Row as Red here
LastColour = 'Red'
End If
LastITRef = CurrentRowITRef
End If
Next
Regards
Edy
Hi Leon,
Leon Lai Kan wrote:
...
1. User will not be required to do any sorting. Sorting has already been done by my query.
...
The problem is usually that the user will try do things anyway, even though they are not required or supposed to. So what I meant is, once you implement a solution, like the one Edy Simonsuggested, and the user sorts the table on another column, what will happen ? Or will you lock the table so the user cannot sort it ?
Leon Lai Kan wrote:
...
2. I prefer to use 2 colours only (say red and blue). Too many colours can be ugly.
...
Edy Simon's suggestion should work nicely, but you should still consider question 1.
Regards,
Johan
Hi Edy,
I have tested your suggestion.
Unfortunately, it did not work at first.
We spent a few hours debugging it, and found what did not work:
When I replaced this line:
Dim CurrentRowITRef As String = "Grid.DataTable.Rows.GetValue("IT Ref", i).ToString
by this one:
Dim CurrentRowITRef As String= Grid.DataTable.GetValue("IT Ref", i).ToString
then your code works perfectly!
It's great!
Thanks again for your generous help.
Best Regards,
Leon
User | Count |
---|---|
103 | |
14 | |
10 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.