Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 668437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:02:22+00:00 2026-05-14T00:02:22+00:00

I’m utilizing the code posted by Jesper Palm here: Make user control display outside

  • 0

I’m utilizing the code posted by Jesper Palm here: Make user control display outside of form boundry

/// <summary>
/// A simple popup window that can host any System.Windows.Forms.Control
/// </summary>
public class PopupWindow : System.Windows.Forms.ToolStripDropDown
{
    private System.Windows.Forms.Control _content;
    private System.Windows.Forms.ToolStripControlHost _host;

    public PopupWindow(System.Windows.Forms.Control content)
    {
        //Basic setup...
        this.AutoSize = false;
        this.DoubleBuffered = true;
        this.ResizeRedraw = true;

        this._content = content;
        this._host = new System.Windows.Forms.ToolStripControlHost(content);

        //Positioning and Sizing
        this.MinimumSize = content.MinimumSize;
        this.MaximumSize = content.Size;
        this.Size = content.Size;
        content.Location = Point.Empty;

        //Add the host to the list
        this.Items.Add(this._host);
    }
}

I’ve translated it to VB:

Public Class PopupWindow
    Inherits System.Windows.Forms.ToolStripDropDown

    Private _content As System.Windows.Forms.Control
    Private _host As System.Windows.Forms.ToolStripControlHost

    Public Sub New(ByVal content As System.Windows.Forms.Control)

        Me.AutoSize = False
        Me.DoubleBuffered = True
        Me.ResizeRedraw = True

        Me._content = content
        Me._host = New System.Windows.Forms.ToolStripControlHost(content)

        Me.MinimumSize = content.MinimumSize
        Me.MaximumSize = content.MaximumSize
        Me.Size = content.Size
        content.Location = Point.Empty

        Me.Items.Add(Me._host)

    End Sub

End Class

It works great with a PictureBox showing its information. But for some reason I cannot get the DataGridView to display anything when it is in the popup.

If I pull the grid out of the popup it displays all of its information fine. If I pause during debug, the grid shows that it has all the data in it. It’s just not displaying anything.

Does anybody have any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:02:23+00:00Added an answer on May 14, 2026 at 12:02 am

    I have not been able to reproduce your problem. Can you provide more code? I’ve been testing in VS2010 RC (.NET 4) and VS2008 (.NET 3.5) and this code works in both:

    public partial class Form1 : Form
    {
        public class Person
        {
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public string PhoneNumber { get; set; }
        }
    
        List<Person> _People;
    
        public Form1()
        {
            InitializeComponent();
    
            _People = new List<Person>();
            _People.Add(new Person() { FirstName = "John", LastName = "Smith", PhoneNumber = "123-456-7890" });
            _People.Add(new Person() { FirstName = "Jane", LastName = "Doe", PhoneNumber = "098-765-4321" });
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
            pictureBox1.Image = Image.FromFile("barcode.png");
            pictureBox1.Location = new Point(-1000, -1000);
    
            dataGridView1.DataSource = _People;
            dataGridView1.Location = new Point(-1000, -1000);
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            PopupControl popup = new PopupControl(pictureBox1);
            popup.Show(new Point(this.Location.X - 128, this.Location.Y));
        }
    
        private void button2_Click(object sender, EventArgs e)
        {
            PopupControl popup = new PopupControl(dataGridView1);
            popup.Show(new Point(this.Location.X - 128, this.Location.Y));
    
            //optionally change the items in the data source
            _People.Add(new Person() { FirstName = "NewFirst", LastName = "NewLast", PhoneNumber = "123-333-3322" });
    
            //reset the bindings
            bindingSource1.DataSource = _People;
            bindingSource1.ResetBindings(true);
        }
    }
    

    Here’s what it looks like:
    alt text http://img534.imageshack.us/img534/1640/popupcontrolwithgrid.jpg

    In the designer, you should setup the BindingSource and assign it as the DataGridView’s DataSource.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 373k
  • Answers 374k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you Send()ing messages or Publish()ing them? If you're publishing,… May 14, 2026 at 7:48 pm
  • Editorial Team
    Editorial Team added an answer You can use a different formatting style to include the… May 14, 2026 at 7:48 pm
  • Editorial Team
    Editorial Team added an answer I don't think so. You need to populate your bsUsers,… May 14, 2026 at 7:48 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.