I'm using a Windows Forms Datagridview to diplay some (long) text. (The code is PowerShell, but the problem is related to the Cell Wrapping mode)
$TestGridView = New-Object System.Windows.Forms.DataGridView -Property @{
Name="TestDataGridView"
AllowUserToAddRows = $False
AllowUserToDeleteRows = $False
Location = "14,225"
Size = "1041,328"
TabIndex = 1
DefaultCellStyle= @{WrapMode ='True'}
RowHeadersVisible=$False
AutoSizeColumnsMode='Fill'
AutoSizeRowsMode = 'AllCells'
Anchor = 'Left, Right, Top, Bottom'
DefaultCellStyle.Padding = new-object Windows.Forms.Padding -a 2
}
I'm using Cell Wrapping and AutosizeRowMode, but I have found no way to have a DGV cell display up to a certain point, then truncate by ellipsis when the cell size is exceeded. What I'd want to accomplish is this: (graphic edit)
but so far, I've been unable to do so:
WrapMode=False,AutoSizeRowsMode=AllCells
truncates by ellipsis, but removes all CRLFs and displays just one line
WrapMode=False,AutoSizeRowsMode=None
Row height set to desired value, but otherwise truncation same as above
WrapMode=True,AutoSizeRowsMode=AllCells
No truncation, all the text is displayed and the cell is adapted in height to fit all the text
WrapMode=True,AutoSizeRowsMode=None
Height stays as it shoulds, but no truncation is performed.
What I'm trying to accomplish is to have the rows adjust in size up to a maximum, after which text should be truncated by ellipsis [...]
I'have already tried truncating the content, but it has the adverse side effect that when the user COPY the cell content, the cell content is missing all the truncated part (of course) so it is not a viable option..
Many thanks