0

In a C# WinForm, DataGridViewTextBoxColumn cell I need to paste set of characters exceeding 32767. It always truncated at 32767.

Thought of implementing CellValueChange event and bind to the relevant cell I need. Is there any other way of implementing this?

tenne
  • 1
  • 1
  • DataGridViewTextBoxColumn has property MaxLinputLength which is an integer. – jdweng Sep 16 '20 at 13:35
  • Thanks @jdweng. Since it's an integer, I set a value larger than 32767 in the properties dialog. Still when I past the test it is limited to 32767. That's the issue I've. – tenne Sep 16 '20 at 13:42
  • CellValueChange event handler also identified up to 32767 characters only. private void dgvAttribLits_CellValueChanged(object sender, DataGridViewCellEventArgs e) – tenne Sep 16 '20 at 13:49
  • Why are you doing it in the change event? Set the property when the grid is initialized. – jdweng Sep 16 '20 at 14:14
  • Max length set at initialization. During runtime user to paste some text larger than 32767. – tenne Sep 16 '20 at 14:39
  • Why don't you just increase the max? It is just a max. I do not think it uses more resources if you increase. Just is a limit. – jdweng Sep 16 '20 at 15:09
  • Yes I did. Set the properties MaxInputLength to 40000 and still trimmed at 32767, when paste the content in the cell. But I can type after that. – tenne Sep 17 '20 at 08:45
  • Then something else is also limiting the length. – jdweng Sep 17 '20 at 09:37
  • Is the content cut off or only the display? – TaW Sep 17 '20 at 12:53
  • @TaW yes, cut off on UI only. If I past (not type) a string larger than default (32767) I can't see anything on UI. But from the backend, correct string is there. That's the content I've pasted. – tenne Sep 21 '20 at 12:19
  • The are some limits on the UI; [one](https://stackoverflow.com/questions/25709069/the-maximum-number-of-characters-a-textbox-can-display/25709337?r=SearchResults&s=1|41.4957#25709337) is that control surfaces can't display more thar 32k pixels in any direction. Yu may have hit one such limit.. – TaW Sep 21 '20 at 12:25
  • I changed the DefaultCellStyle, and it works now. Seems the issue is when wrapping the content. DataGridViewCellStyle { WrapMode=True } – tenne Sep 23 '20 at 15:46

0 Answers0