- Is there a way to tell the Grid show only these 3 out of 100 columns in the table? I know how I hide the other 97 but I am hoping there is a better way.
- Same question for the child band. The table that is bound to the child band also has numerous fields and I care to show only a few fields on the child band
Thanks!
Thanks for taking time to reply.
if (!((IList<string>)DisplayFields).Contains(column.Key)) {
}
The above approach saved me several additional lines of code.
I think i know what you are looking for. I do this with a FOR loop in the InitizlizeLayout.
Select Case oCol.Key
Case "GoodCol_A", "GoodCol_B", "GoodCol_C"
oCol.Hidden = False
Case Else
oCol.Hidden = True
End Select
Next
You might want to try this:
HOWTO:How can I define columns in the grid at Design-time and bind them at run-time so that some fields of the data are excluded from the grid?
But this won't really be any more efficient and it's probably safer to do it at run-time, since the VS form designer can be a bit quirky when it comes to data binding.
Mike Saltzman"] I don't understand your question. You say you know how to hide the columns, but you are asking how you can hide the columns?
I don't understand your question. You say you know how to hide the columns, but you are asking how you can hide the columns?
Currently I am having to maintain a list of a few fields that I would like to display. Then iterate over the list of columns and set most of them to hidden. I was wondering if I could do something in the reverse i.e. provide the Grid a list of columns that I want to display and Grid would hide the rest. Sounds like there isn't a way to do that.
If by "a better way", you mean a way to remove the columns, then no, there is no way to do that. The grid will create columns based on the fields in the data source. You cannot prevent it from creating a column except by removing or hiding that column in the data source so that it is not returned by the DotNet BindingManager.