Hi John,
I agree what Ciaran has suggested.
The Graghics.MeasureString method has several overloads. To determine
whether a specified string when drawn with the specified Font within a
limited width is clipped, we could use the certain overload
Graphics.MeasureString(String, Font, Int32).
Use the above method in your PC application. In your scenario, pass the
string to be checked, the font("Microsoft Sans Serif", 18pt) and the width
value of the label in your device application to the method.
To obtain a Graphics, you could call the form's CreateGraphics method.
The following is a sample.
Function MeasureStringHeight(ByVal text As String, ByVal font As Font,
ByVal maxwidth As Int32) As Single
' Me refers to the form
Dim g As Graphics = Me.CreateGraphics
Dim textsize As SizeF
textsize = g.MeasureString(text, font, maxwidth)
Return textsize.Height
End Function
You could call this function before saving the data into DB. If the
returned height value is greater than the height value of the label in your
device application, set the focus back to the textbox and show an alert
text with an error provider besides the textbox.
You could also handle the Validating event of the textbox and call the
above MeasureStringHeight in the event handler. If the result is greater
than the height value of the label in your device application, set the
Cancel property of the System.ComponentModel.CancelEventArgs class to false.
Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.