问题
I'm looking to display multiple records in a data-aware WinForms grid control, such that the column-headers become (repeating) row-labels. Does the grid of any of the major third-party WinForms control vendors have this feature, or can it be done with the built-in grid control? Or is there a way to simulate it using labels and textboxes and datepickers in a control that offers repeating vertical groups?
City xxxxxxxxxxxxxxxxxxxxxx
State xx
Zip xxxxx
Note xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-------
City xxxxxxxxxxxxxxxxxxxxxx
State xx
Zip xxxxx
Note xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-------
City xxxxxxxxxxxxxxxxxxxxxx
State xx
Zip xxxxx
Note xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
回答1:
Is there a way to simulate it using labels and textboxes and datepickers in a control that offers repeating vertical groups?
You can use either of these options:
DataReapter
You can use a DataRepeater control.The Visual Basic Power Packs DataRepeater control is a scrollable container for controls that display repeated data, for example, rows in a database table. It can be used as an alternative to the
DataGridView
control when you need more control over the layout of the data. TheDataRepeater
"repeats" a group of related controls by creating multiple instances in a scrolling view. This enables users to view several records at the same time.Custom UserControl shown in TableLayoutPanel or FlowLayoutPanel
You can create a customUserControl
which shows a record this way and then using aTableLayoutPanel
orFlowLayoutPanel
show all records.Custom DataGridViewColumn
You can create a customDataGridViewColumn
hosting a complex (user control) which shows the whole object behind the row this way.
来源:https://stackoverflow.com/questions/36941509/winforms-datagrid-inverted-so-that-column-headers-become-repeating-row-labels