"Peter Duniho" <(E-Mail Removed)> skrev i meddelandet
news:R7-(E-Mail Removed)...
> On 3/16/11 8:02 AM, Tony Johansson wrote:
>> [...]
>> Have I missed something here ?
>
> Definitely. But since you haven't bothered to post a concise-but-complete
> code example that reliably reproduces the problem, well.you know the rest.
>
> Pete
Here is complete example where I use Button and it doesn't work as expected.
As you can see in the code I first put one button in the panel with a text
First and then
I put a second button in the panel with a text Second. This second Button is
positioned a litte bit to the right
from the first button. I use BringTofront to make the last button the
topmost but instead it will be put under the first button so the first
button is always the topmost
Is this perhaps a bug because it doesn't work as it should ?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Slask
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
for (int i = 0; i <= 1; i++)
{
Button btn = new Button();
int xPos = (i % 2) * btn.Width / 2;
btn.Location = new Point(xPos, 0);
btn.BringToFront();
if (i == 0)
btn.Text = "First";
else
btn.Text = "Second";
panel1.Controls.Add(btn);
}
}
}
partial class Form1
{
/// <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.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panel1
//
this.panel1.Location = new System.Drawing.Point(12, 26);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(268, 197);
this.panel1.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 270);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
}
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
//Tony
|