|
Nnamdi Onyeyiri wrote:
im making my own one,
Good luck then! how's yours different? it is suitable for general-case use? if so, you could write an article for CP
Cheers,
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
In my main form's code, it has a button for adding another tabbed pane with
the following handling code:
<br />
private void button2_Click(object sender, System.EventArgs e)<br />
<br />
{<br />
<br />
BidPage bp = new BidPage(tabControl1);<br />
<br />
bp.Location = new System.Drawing.Point(4, 22);<br />
<br />
bp.Size = new System.Drawing.Size(552, 326);<br />
<br />
bp.TabIndex = this.tabControl1.TabCount + 1;<br />
<br />
bp.Text = "BidPage" + currID;<br />
<br />
tabControl1.TabPages.Add(bp);<br />
<br />
<br />
<br />
currID++;<br />
<br />
}<br />
<br />
However, when a new BidPage is added, it's supposed to contain a button, but
it's blank! What's going on? Here's the BidPage class code:
<br />
<br />
using System;<br />
<br />
using System.Windows.Forms;<br />
<br />
namespace WindowsApplication1<br />
<br />
{<br />
<br />
<br />
<br />
<br />
public class BidPage : TabPage<br />
<br />
{<br />
<br />
private Button removeButton;<br />
<br />
private System.Windows.Forms.Label label1;<br />
<br />
private System.Windows.Forms.Button remButton;<br />
<br />
private TabControl parentTabControl;<br />
<br />
public BidPage(TabControl tcOwner): base()
<br />
{<br />
<br />
<br />
<br />
<br />
InitializeComponent();<br />
<br />
parentTabControl = tcOwner;<br />
<br />
}<br />
<br />
private void InitializeComponent()<br />
<br />
{<br />
<br />
this.SuspendLayout();<br />
<br />
this.label1 = new System.Windows.Forms.Label();<br />
<br />
this.remButton = new System.Windows.Forms.Button();<br />
<br />
<br />
<br />
<br />
this.label1.Location = new System.Drawing.Point(17, 17);<br />
<br />
this.label1.Name = "label1";<br />
<br />
this.label1.TabIndex = 0;<br />
<br />
this.label1.Text = "label1";<br />
<br />
this.label1.Click += new System.EventHandler(this.label1_Click);<br />
<br />
<br />
<br />
<br />
this.remButton.Location = new System.Drawing.Point(98, 17);<br />
<br />
this.remButton.Name = "remButton";<br />
<br />
this.remButton.TabIndex = 0;<br />
<br />
this.remButton.Text = "remove tab";<br />
<br />
this.remButton.Click += new System.EventHandler(this.remButton_Click);<br />
<br />
<br />
this.ResumeLayout(false);<br />
<br />
}<br />
<br />
private void remButton_Click(object sender, System.EventArgs e)<br />
<br />
{<br />
<br />
parentTabControl.TabPages.Remove(parentTabControl.SelectedTab);<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
|
|
|
|
|
After you 'new' the button, you must then add a call to this.Controls.Add(remButton) . This tells the TabPage that it is the "Owner" of the button and should then display it, if remButton.Visible = true. You can do this either in the Initialize() or in the constructor.
Later,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
How can I stop a form from redrawing itself while I make a lot of changes to its child controls?? In Win32 there is the WM_SETREDRAW (or is it WM_REDRAW) message. Is there a way to do it in Windows Forms? Or do I have to send the message to the Windows the Win32-way? if so, how do I do that?
Thanks,
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
You can use this method:
Control.SuspendLayout Method
(from help)
"The layout logic of the control is suspended until the ResumeLayout method is called.
The SuspendLayout and ResumeLayout methods are used in tandem to suppress multiple Layout events while you adjust multiple attributes of the control. For example, you would typically call the SuspendLayout method, then set the Size, Location, Anchor, or Dock properties of the control, and then call the ResumeLayout method to allow the changes to take effect."
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Hi, try adding these 2 lines to the constructor of the form/control:
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
From the MagicLibrary help file:
The first line will request that double buffering be used whenever the OnBackground or OnPaint methods are called. This will reduce the amount of flicker but may not remove it completely as painting the whole control still results in two separate blitting operations.
The second line of code above is used to ensure that only a single blitting operation occurs when drawing. This occurs when the underlying windows WM_PAINT message is processed. When this happens it will create the memory bitmap, call the OnBackground method, call the OnPaint method and then finally blit the result to the screen.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
This doesn't stop the form from painting itself while everything is being moved. It does stop most of the flickering involved but with him moving/resizing controls more will have to be done to prevent the redrawing.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
I added those two lines, and it caused some problems... the toolbar appeared with the images on top of what was previously where my window appeared (background not erased) and if I moved a dialog on top of it, it did not repaint itself well.
But I removed a great deal of flicker by changing the order of making controls visible and invisible, moving panels and so on.
Thank you all for your help!
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
What about SuspendLayout ? did it work ?
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Andres Manggini wrote:
What about SuspendLayout ? did it work ?
No. I tried it also, but I have to call it for each control (for the toolbar, status bar, outlook bar, different panels, and so on) and when I called ResumeLayout for each, the same flicker occured because it first did everything for the toolbar and painted, then the outlook bar and repainted, and so on... But thanks anyway for your help,
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
I meant to use the method on the form, not each control, I thought that was what you were looking for.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
I first tried calling the form's method, but nothing happened differently... As I understood the documentation, calling SuspendLayout acts only on changes in the control's own Location, Size, Dock and Anchor properties, not on its children's.
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Anybody knows how to implement the Context Sensitive Help? I looked into the MSDN there is no example and no hint how to do it, also I worked with HelpProvider class but unable to achieve it. Is anybody can help me in this or send me link where I can get the info about it.
Thanks in advance.
|
|
|
|
|
i have a static arraylist Commands , and a struct SvrCmd
i have used the following code to create a static member of type SvrCmd, and also add that static member, to the Commands array list
public static SvrCmd Abor = new SvrCmd();
Abor.Cmd = "ABOR";
Abor.Description = "Abort Transfer";
Commands.Add(ServerCommand.Abor); and i get a whole load of errors.
oh yer, the SvrCmd struct has public string members Cmd and Description
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
|
|
Nnamdi Onyeyiri wrote:
Commands.Add(ServerCommand.Abor);
What is ServerCommand? You say you have a SvrCmd type.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
lol
ServerCommand is the class that the code is in.
SrvCmd is just a struct, wiv two variables string Cmd and string Description
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Hi again,
It must be late or I'm just plain thick, but what is the purpose for the members to be static?
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
its holding information. i just didnt want to have to create instances, fore what i had in min,d i didnt see the point.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
|
im not - thats why its static.
Abor is in a class called ServerCommand
SrvCmd is a struct, which ive used to make the Abor object.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Nnamdi Onyeyiri wrote:
im not - thats why its static.
You are!!!
public static SvrCmd Abor = new SvrCmd();
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
im iticating a static member of type svrcmd in another class, because i want each of the static variables to hold two pieces of information.
anywayx, no need to get ur knickers in a twist, rama solved it for me, i had to put the code where i assigned a value to Abor in a constructos.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|