Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

messagebox size?

Posted on 2006-06-16
3
Medium Priority
?
481 Views
Last Modified: 2008-02-01
Hi

I do

MessageBox.Show("No response from " + listBox1.SelectedItem.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

but sometimes listBox1.SelectedItem is quite long (over 30 characters)

And this seems to make the messagebox massive (way bigger than required)

Is there a way to avoid a lot of whitespace?

Thanks
0
Comment
Question by:boofulls
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
pgloor earned 80 total points
ID: 16919237
Idea: Split your message (e.g. into word tokens) and add a NewLine after any 50 characters or so, before showing the message on the screen.
--------------------------------------------------------------------------------------------------

const int LINE_SIZE = 50; // Max # of characters / line
String message = "No response from " + listBox1.SelectedItem.ToString();
string output = "";
String [] wordTokens = message.Split(new Char [] {' '});
int count = 0;
foreach (String token in wordTokens) {
  if (count + token.Length > LINE_SIZE) {
    output += Environment.NewLine + token;
    count = token.Length + 1;
  } else {
    if (output.Length == 0) {
      output = token;
      count = token.Length + 1;
    } else {
      output += " " + token;
      count += token.Length + 1;
    }
  }
}
MessageBox.Show(output, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question