May I ask some ideas where did I miss?
You missed to describe the issue you get and/or error message, which we can't guess.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Good morning, everyone! I am currently working on my first project in Visual Studio and I encountered that problem. May I ask some ideas where did I miss?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Student_Activity_Tracker
{
public partial class Form1 : Form
{
Form2 form;
public Form1()
{
InitializeComponent();
form = new Form2(this);
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
public void Display()
{
ATStudent.DisplayAndSearch("SELECT ID, Subject, Activity, Dos FROM student_table", dataGridView1);
}
private void btnNew_Click(object sender, EventArgs e)
{
form.Clear();
form.ShowDialog();
}
private void Form1_Shown(object sender, EventArgs e)
{
Display();
}
private void txtSearch_TextChanged(object sender, EventArgs e)
{
ATStudent.DisplayAndSearch("SELECT ID, Subject, Activity, Dos FROM student_table WHERE Subject LIKE '%"+ txtSearch.Text +"%'", dataGridView1);
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if(e.ColumnIndex == 0)
{
//edit
form.Clear();
form.ID = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
form.Subject = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
form.Activity = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
form.Date = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
form.UpdateInfo();
form.ShowDialog();
return;
}
if(e.ColumnIndex == 2)
{
//delete
if (MessageBox.Show("Do you want to delete the record?", "Information", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information) == DialogResult.Yes)
{
ATStudent.DeleteStudent(dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString());
Display();
}
return;
}
}
}
}
May I ask some ideas where did I miss?
You missed to describe the issue you get and/or error message, which we can't guess.
In short, inaccessable due to its protection level
means you are trying to access a control in the other form with it's Modifiers
property set to private
and to access it you need to change it to public
. Similarly if a property or method is setup as private you need to change to public.