在MeasureString方法中使用长字符串时抛出异常?

时间:2017-01-12 06:23:44

标签: c# string datagridview graphics

我在WinForms项目中工作。在那里,我有单元格值作为字符串,Size.Width是(288600)。我根据单元格宽度(350)包装了该字符串值。当文本宽度达到(173800)时它不会引发异常,但是当超过文本宽度173800时它会抛出异常。请建议我为什么会出现不同文本宽度的异常。这里我提供了字符串值,我使用的方法和异常细节。 private const string LongString = "Equals \"1000158.3, 1000530, 1001129.4, 1001543.4, 1001641.5, 1002420, 100278, 100350, 100386, 1005291, 100561.5, 1005705.9, 1005895.8, 100701.9, 10071, 100773, 1008, 10080, 100800, 1008000, 10080000, 1008506.7, 100890, 1009021.5, 1009156.5, 1009192.5, 1009300.5, 1009530, 100980, 101016, 1010296.8, 1010970, 101124, 101124.9, 1011368.7, 1011690, 101250, 1012500, 101269.8, 101340, 101439, 1014403.5, 1015140.6, 1015147.8, 10152, 1015219.8, 1015290, 101530.8, 1015717.5, 1016172.9, 1016706.6, 10170, 101700, 10170000, 1017000000, 101719.8, 1017378.9, 10174.5, 101757.6, 1018554.3, 1019005.2, 102022.2, 102023.1, 102144.6, 102285.9, 102286.8, 1023558.3, 1023570, 102446.1, 1025623.8, 1026, 102600, 10260000, 10269, 1027585.8, 102853.8, 103104, 103118.4, 1032340.5, 1032966, 1033407, 1033587, 1034428.5, 103455, 103458.6, 103467.6, 1034874, 10350, 103500, 1035000, 10350000, 103518, 103558.5, 103693.5, 1037279.7, 1037604.6, 103764.6, 1037664, 10381.5, 103837.5, 1038688.2, 1038855.6, 103887, 1039365, 103950\""; SizeF stringSize = g.MeasureString(LongString, this.Font, 350, new StringFormat());

enter image description here

0 个答案:

没有答案