Form

GPALDataGridView

Everything on Settings Every Control Takes applies here too. GPAL.DataGridView builds one. WithInput takes an IGPALGrid, a DataTable, an IGPALDatabase whose query it runs, or a GPALFile it tokenizes, and the column names come from the source. WithColumns names them instead, and WithAutoGenerateColumns lets the grid build them from the data.

WithColumnWidth takes pixel widths in column order, or shares as doubles which reflow with the form. WithWrap says which columns wrap their text, in column order, and said with no arguments every column wraps; rows then grow to hold what wrapped rather than clipping it.

WithStartRow, WithEndRow, WithStartColumn and WithEndColumn bound what GetGrid reads back out, not what the grid displays. They are one-based, and a value of zero or less means no bound on that side.

WithReadOnly stops the user editing cells. GetGrid reads the contents back out as an IGPALGrid, including anything the user typed. CellValueChanged is the event for an edit. GPAL.DataGridViewFor(columns) is the shorthand.

NOTE

A wrapped column earns its place where the value is a sentence, a message or a path. Everywhere else it costs: rows are as tall as their tallest cell, so one wrapping column makes every row ragged and a table that could be scanned stops being scannable. Fewer entries than there are columns leaves the rest on one line, so naming the one column that needs it is the usual call.

Examples

GPAL Fluent: High-level fluent C# API

//The last column takes whatever width the others leave, so the row ends at the edge of the control rather than leaving a strip that is not a column.

GPALDataGridView rows = (GPALDataGridView)GPAL.DataGridView

.WithInput(orders)

.WithColumnWidth(0.4, 0.3, 0.3)

.WithWrap(false, false, true) // only the last column wraps

.WithReadOnly(false)

.WithCallback<DataGridViewCellEventHandler>(CellEdited).ForEvent(ControlEventType.CellValueChanged)

.WithName("rows");


// after the form closes, read back what the user left

rows.GetGrid(out IGPALGrid<string> edited);

💬 Ask GPAL