protected override void OnColumnAdded(DataGridViewColumnEventArgs e) {
base.OnColumnAdded(e);
if (e.Column.Index == 5) {
e.Column.ReadOnly = true;
}
}
Column Count Error in datagridview
OmkarHcl
206
Reputation points
public partial class sale_purchase_datagridview : DataGridView
{
private SqlConnection con;
private SqlDataAdapter da;
private DataTable dt, dt2;
public sale_purchase_datagridview()
{
this.Columns[5].ReadOnly = true;
InitializeComponent();
}
protected override void OnEnter(EventArgs e)
{
base.OnEnter(e);
}
t
The problem is what i want is that , the column 5 of sale_purchase_datagridview must always be readonly . Although there is one thing due to this the error is popping , i have not add the columns in this custom datagridview itself . I have added the columns in the form where i am using this control . So is there a way by which i can achieve this ?
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,927 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,429 questions
Accepted answer
-
KOZ6.0 6,580 Reputation points
2023-10-08T12:27:01.52+00:00