- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an iLogic for automating some operations with the revision table. One of the operations allows the user to add to the current revision if certain conditions are met. The user is prompted for text to add to the revision description with an input box, which then inserts it in to the current revision description cell.
I am trying to add a check to this process to see if the text the user wants to add (not including the existing text) will fit on a single line or will wrap. I attempted to use this code to do so:
Dim moreDescText As String
Do
moreDescText = InputBox("Description text to add:", "Insert additional info to Model Change Rev")
If System.Windows.Forms.TextRenderer.MeasureText(moreDescText, New System.Drawing.Font("Tahoma", (.05 * 72), System.Drawing.FontStyle.Regular)).Width < 120 Then
Logger.Info(System.Windows.Forms.TextRenderer.MeasureText(moreDescText, New System.Drawing.Font("Tahoma", (.05 * 72), System.Drawing.FontStyle.Regular)).Width.ToString)
Exit Do
Else
Select Case MessageBox.Show("The new description you are adding will go onto two lines. Do you want to retry?", "Text Wrap Detected", MessageBoxButtons.AbortRetryIgnore)
Case DialogResult.Ignore
Exit Do
Case DialogResult.Abort
Return
Case DialogResult.Retry
'loop
Case Else
Logger.Info("what else could there be?")
End Select
End If
Loop
The 120 value for the string measurement was selected through trial and error, but doesn't always work which is why I'm here 🙂
Is there a better way to check for wrapping text, or to determine how many pixels are available in the revision table cell on a single line in the file the rule is being run in?
Solved! Go to Solution.