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

  • Home
  • SEARCH
  • 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 7628271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:34:21+00:00 2026-05-31T05:34:21+00:00

I need help with accessing class from Form. So I’ll put my code so

  • 0

I need help with accessing class from Form.

So I’ll put my code so you can see what I mean.

So I have made several classes. For example:

public class Landscape
{
    public DataGridView grid;

    public void init()
    {
        grid = new DataGridView();
        // 
        // grid
        // 
        grid.AllowUserToAddRows = false;
        grid.AllowUserToDeleteRows = false;
        grid.AllowUserToResizeColumns = false;
        grid.AllowUserToResizeRows = false;
        ...
        grid.AutoSizeColumnsMode = grid.Size = new System.Drawing.Size(790, 427);
        grid.TabIndex = 0;
    }
}

So basically this would make me datagridview on my form.

When I create form:

public partial class MyScreen: Form
{
    public MyScreen()
    {
        InitializeComponent();
        Landscape land=new Landscape();
        land.init(); //this should draw me datagrid on my form
    }
}

Shouldn’t this code draw me my datagrid into form?

How to achieve this?

You mean something like:

public partial class MyScreen: Form
{
    public MyScreen()
    {
        InitializeComponent();
        Landscape land = new Landscape();
        this.Controls.Add(land.grid);
        land.init(); 
    }
}

But it’s not working…

  • 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-31T05:34:22+00:00Added an answer on May 31, 2026 at 5:34 am

    No, because you have just created a data grid view in a class but not added it to the forms controls. Add the line

    land.init();
    this.Controls.Add(land.grid);
    

    To add the control to the form

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

Sidebar

Related Questions

i need help with disk_total_space function.. i have this on my code <?php $sql=select
I need help with accessing class properties within a given class. For example, take
Need help writing a script downloads data from google insight using c# this is
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need help understanding some C++ operator overload statements. The class is declared like
My brain is not working this morning. I need some help accessing some members
I have to create a pdf report from several classes that are going to
I am new to Ruby and need help in accessing a function which is
I need help with users accessing my site via HTTPS. I only want to
I need help with configuring Reporting Services. I have the ReportServer and Report Manager

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.