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
sachi vasishta
NA
252
0
datagridview's column's width problem
Jun 1 2009 2:48 AM
Hi,
In a form's form_load event I will retrive some info from db and display it on the dgv. Before I will display it on the dgv I want to change the width of some of dgv's columns, for that I have written the following code but when I run this it is giving me the following error.
ArgumentOutOfRangeException was unhandled.
Index was out of range. Must be non-negative and less than the size of the collection.
private
void
Form40_Load(
object
sender,
EventArgs
e)
{
Form41
.ActiveForm.Close();
dataGridView1.Columns[1].Width = 300;
dataGridView1.Columns[2].Width = 300;
dataGridView1.Columns[10].Width = 350;
Class1
obj =
new
Class1
();
string
sql =
string
.Format(
"select officeid as Hospital_Id,officename as Hospital_Name,address as Address,city as City,state as State,zip as Zip,officephno as Phone,fax as Fax,tollfreeno as TollFree_No,officeemail as Email from officetable"
);
DataTable
dt =
new
DataTable
();
dt = obj.gettable(sql);
dataGridView1.DataSource = dt;
obj.closecon();
}
Reply
Answers (
2
)
dll
how to declare an empty string array -small doubt in the code