DataGrid not working in UserControl
  • Hello,

    I am trying to have a dataGrid inside a userControl, and then I'm loading that userControl into a tabControl as follows:
    UserControl userControl = new userControl1();
    tabPage1.PageVisible = true;
    tabPage1.Controls.Add(userControl);
    userControl.Dock = DockStyle.Fill;
    userControl.Show();
    My problem is that when the userControl is loaded into the tabPage I click on a button that is also on the userControl. The button is supposed to populate the dataGrid, but nothing is happening when I click the button to populate it.
  • 4 Comments sorted by
  • hi @johnmcmil
    may be you doing something wrong in your code because i make one user control with datagridview as you said and using it another project and attaching my projects kindly check it.
    UserControlWithGrid.zip
    70K
  • @Waqas Yes, thank you for your reply. I checked out your project, and it's working for me. So I replicated it myself, and it was working. Then I created a new project and loading the userControl into the tabControl again, and no work that way.
    So I'm not sure what to do about it. Let me know your results on this, please. This is a shortened way of what I'm using, and seems not working for me.
    Pasgan ùr.rar
    53K
  • i @johnmcmil , don't know what exactly problem with your program because i download your project and add it in visual studio 2008 project and its perfectly working kindly download attached code and snap of result.


    image
    WindowsFormsApplication6.zip
    45K
    UserContol.jpg
    1024 x 768 - 195K
  • Okay @Waqas, well thank you for looking at it. Your project also did not work. I will further look in this, hopefully with resolve.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Tagged

Popular Posts of the Week

    Optimum Creative