Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2008

Tip: Looking for answers? Try searching our database.

drawing issue with modeless window

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Smith - 14 Jan 2008 18:34 GMT
I have a popup window created from a form that contains a progress bar and a
label field.  The problem is while the progress bar updates fine, the label
field does not show up at all on the form.

I have tried a couple of different things, but nothing seems to make the
label field to show.

Any ideas?

Thanks.
Bob Powell [MVP] - 14 Jan 2008 19:39 GMT
Are you using databinding?

Can you post some code...

Signature

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

>I have a popup window created from a form that contains a progress bar and
>a
[quoted text clipped - 8 lines]
>
> Thanks.
Nathan Smith - 14 Jan 2008 20:36 GMT
No data binding.  Here's what I'm doing...
[Sample start]
'create a progress window
Dim progDlg As New Banner
progDlg.TextBox1.Text = "Please Wait..."
'set the progress bar to start pos
progDlg.ProgBar.Increment(10)
progDlg.Show()
[Sample End]

> Are you using databinding?
>
[quoted text clipped - 12 lines]
> >
> > Thanks.
Bob Powell [MVP] - 15 Jan 2008 09:14 GMT
Without actually seeing how you're communicating with the progress window
it's a bit difficult to make a reccomendation. To illustrate how I might
accomplish the same thing I have included a project in the text below my
signature.

Signature

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

------------------------------------------------------
namespace Progresswindow

{

public class Form1 : Form

{

int progress = 0;

Timer t;

Progress dlg = new Progress();

public Form1()

{

InitializeComponent();

}

private void StartProgress()

{

progress=0;

t = new Timer();

t.Interval = 100;

t.Tick += new EventHandler(t_Tick);

t.Enabled = true;

dlg.ShowDialog();

}

void t_Tick(object sender, EventArgs e)

{

progress++;

if (progress < 101)

dlg.ProgressValue = progress;

else

{

t.Enabled = false;

t = null;

}

}

private void button1_Click(object sender, EventArgs e)

{

StartProgress();

}

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.IContainer components = null;

/// <summary>

/// Clean up any resources being used.

/// </summary>

/// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.button1 = new System.Windows.Forms.Button();

this.SuspendLayout();

//

// button1

//

this.button1.Location = new System.Drawing.Point(85, 111);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(75, 23);

this.button1.TabIndex = 0;

this.button1.Text = "Start";

this.button1.UseVisualStyleBackColor = true;

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// Form1

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(284, 264);

this.Controls.Add(this.button1);

this.Name = "Form1";

this.Text = "Form1";

this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Button button1;

}

public class Progress : Form

{

int progress;

public int ProgressValue

{

get { return progress; }

set

{

if (value == 100)

{

this.Close();

}

else

{

progress = value;

this.progressBar1.Value = value;

this.label1.Text = value.ToString();

}

}

}

public Progress()

{

InitializeComponent();

}

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.IContainer components = null;

/// <summary>

/// Clean up any resources being used.

/// </summary>

/// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.progressBar1 = new System.Windows.Forms.ProgressBar();

this.label1 = new System.Windows.Forms.Label();

this.SuspendLayout();

//

// progressBar1

//

this.progressBar1.Location = new System.Drawing.Point(12, 50);

this.progressBar1.Name = "progressBar1";

this.progressBar1.Size = new System.Drawing.Size(260, 23);

this.progressBar1.TabIndex = 0;

//

// label1

//

this.label1.Location = new System.Drawing.Point(12, 24);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(260, 23);

this.label1.TabIndex = 1;

this.label1.Text = "label1";

this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

//

// Progress

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(284, 90);

this.Controls.Add(this.label1);

this.Controls.Add(this.progressBar1);

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;

this.MaximizeBox = false;

this.MinimizeBox = false;

this.Name = "Progress";

this.Text = "Progress";

this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.ProgressBar progressBar1;

private System.Windows.Forms.Label label1;

}

}

-------------------------------------------------------

> No data binding.  Here's what I'm doing...
> [Sample start]
[quoted text clipped - 24 lines]
>> >
>> > Thanks.
Nathan Smith - 15 Jan 2008 13:20 GMT
It looks like you're using ShowDialog instead of Show to open the window.  I
was under the assumption that I needed to use Show when opening modeless
dialogs and ShowDialog when opening modal dialogs - is this not the case?

All this dialog is for is to popup and give the user a message along with
progress of the current operation - there is no user input.  When the
operation is finished the window is close by the app.

I am updating the progress bar using the progress bar Increment method.  The
bar shows and works fine - it's just the label field that I put in the window
that doesn't show at all - even if that's the only field on the dialog.

Thanks for the help!

> Without actually seeing how you're communicating with the progress window
> it's a bit difficult to make a reccomendation. To illustrate how I might
> accomplish the same thing I have included a project in the text below my
> signature.
Bob Powell [MVP] - 18 Jan 2008 21:15 GMT
Ah, it's funny you should say that but I did the demo with Show first of all
and then decided that wasn't what you were describing.

Personally I would say that any popup progresss should really be modal so
that the user can be informed of the action taking place without insisting
that they do something at the same time. If you want tasks to carry on
asyncrounously then a progress bar in a status bar control is a far better
UI option.

Signature

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> It looks like you're using ShowDialog instead of Show to open the window.
> I
[quoted text clipped - 17 lines]
>> accomplish the same thing I have included a project in the text below my
>> signature.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.