Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Status Strip Label not big enough

Status
Not open for further replies.

rhfritz

Programmer
Apr 20, 2011
1
US
My Layout looks like this:
--------------------------------------------------------------|
Textstatuslabel0|Textstatuslabel1| Textstatuslabel3|
--------------------------------------------------------------|
All fields above are AutoSize = True. Textstatuslabel3 has Spring=True.

Window sized properly:
------------------------------------------------|
Textstatuslabel0|This message is fully displayed|
------------------------------------------------|

Current Behavior if the above window is resized smaller than
required for Textstatuslabel1 Text:
---------------------------------------|
Textstatuslabel| |
---------------------------------------|
i.e. Not even a portion of the message is displayed or a hint that it is truncated, e.g. ... or something. The message does appear if/when you resize the window.

What I would want is to somehow detect this condition so that I could either pop up a message box, resize the form to fit the text or otherwise display a partial version. But right now there's no clue that the window is too small for the message and the user misses the notification.
 
I'm assuming based on forum of your question that you're using MS Visual Studio. I've used it very little, but I know it's very similar to using MS Access forms - VBA and other applications for form design... including Visual Studio pre .Net..

Anyway..

Have you looked at putting some code into an event such as... Form.Dirty or Form.Change or soemthing similar? Seems to me that you could have some code in there which basically checks for the like of:

If Form.Width < 4 Then
/*Do whatever you need to do*/ - just guessing at comment notation, as don't remember off hand.

End If

....
Man, I need to really start doing some building and testing with C#, myself, in studio - have heard so many good things, just hard to find the time and motivation. Too bad I can't use it at work. [smile]
...
 
Add a icon, which is docked in a corner, so it's always visible.
Determine whether or not to show based on the lower corner of the error label being "on screen". Note you will have to add vertical check as well.

Be wary of labels that will still clip, because the border of the application is counted in the size.

Code:
        private void button1_Click(object sender, EventArgs e)
        {
            DisplayErrors(DateTime.Now.ToLongDateString(), label1);
        }

        private void DisplayErrors(String textToShow, Label targetLabel)
        {
            targetLabel.Text = textToShow;
            //PictureBox1 is located at 0,0 of the form
            pictureBox1.Visible = (targetLabel.Location.X + targetLabel.Size.Width > this.Size.Width);
        }

HTH,

Lodlaiden

If [blue]you have problems[/blue], I want [green]source code[/green] AND [green]error messages[/green], none of this [red]"there was an error crap"[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top