TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sreedevi v
NA
166
5.3k
Add button dynamically in first column of DataGridView
Apr 12 2019 12:25 AM
int[] colWidth = {5,10, 17 };
string[] colAlign = { "C", "L", "L" };
string[] colTabStop = { "False", "True", "True" };
string[] Colheader = {"Sl No", "Product ID", "Product Name"};
private void initgrid()
{
DataTable dt = new DataTable();
dt = purchasesb.GetPEByNO("");
for (int i = 0; i < dt.Columns.Count; i++)
{
dgvdetails.Columns.Add(dt.Columns[i].ColumnName, Colheader[i]);
if (colAlign[i] == "R")
{
dgvdetails.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
dgvdetails.Columns[i].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
}
else if (colAlign[i] == "C")
{
dgvdetails.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dgvdetails.Columns[i].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
}
else
{
dgvdetails.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
dgvdetails.Columns[i].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
}
if (colTabStop[i] == "False")
{
dgvdetails.Columns[i].ReadOnly = true;
}
else
{
dgvdetails.Columns[i].ReadOnly = false;
}
dgvdetails.Columns[i].Width = Convert.ToInt32(((colWidth[i] * panel2.Size.Width) / 100));
}
}
This is my code.
How to add button dynamically in firstcolum((ie when i=0) of DataGridView- dgvdetails?
Reply
Answers (
1
)
How to save images to a folder with its original name?
how to get opening and closing balance using datagridview