I am not sure if this is a bug, or I am doing something wrong.
I have a DataGridView that I am binding a DataTable to and I am and trying to have the row only display a single line.
My TextBoxColumn has some rows that have strings that have new line breaks in them.
In this case I only want to display the first line. I have set all the properties for the default cells and rows to:
WordWrap: false
Multiline: false
However I still seem to be getting multline text results. Am I missing something or is there a multiline issue here?
Thanks,
Devin
Hi Devin,
can you please wrap up a small compilable repro case and a description of the expected behavior?
Thanks in advance,
Frank
Hi Devin,
I wanted to clarify the properties and their functionalities:
The Newlines character have nothing to do with word wrapping, since it’s a line wrap!
HTH,
Alaa
Hi Frank,
Thank you for your reply, I have attached some screenshots which the desired outcome and a sample program
The screenshot “sample-desired-result.png” I created manually with only single line data rows.
The screenshot “sample-results.png” is what the sample project displays.
WordWrap and Multiline properties have been set to False, maybe I am missing something else.
Thank you for your help again,
Devin
Alaa,
I see multiline is for cell editing.
Is there any way to display a single line then? or do you have bind only a single line string?
Thanks,
Devin
Alaa,
I see multiline is for cell editing.
Is there any way to display a single line then? or do you have bind only a single line string?
Thanks,
Devin
Hi Devin,
You should be able to handle the Formatting event and replace the newline tokens like the following:
private void DataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) {
if (e.ColumnIndex == 0 && e.Value is string)
e.Value = ((string)e.Value).Replace("\r\n", "¶");
}
HTH,
Alaa
Hi Alaa,
Yup that works
Perfect
Devin
Please login first to submit.