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
ahmed salah
NA
530
148.9k
How to make default value for combobox with selectedvalue=0
Jan 24 2017 8:27 AM
Hi i work in visual studio 2015 with c# windows form
i need to assign default value with value 0 and text select to combox
but How can i do that ?
In windows form load i make
var fileName =
string
.Format(
"{0}\\Book3105"
, Directory.GetCurrentDirectory());
var connection =
string
.Format(
"Provider=Microsoft.ACE.OLEDB.12.0;"
+
"Data Source={0};Mode=ReadWrite;Extended Properties=Excel 12.0 Xml;"
, fileName);
OleDbConnection con =
new
OleDbConnection(connection);
try
{
con.Open();
str =
"select * from [sheet2$]"
;
com =
new
OleDbCommand(str, con);
oledbda =
new
OleDbDataAdapter(com);
ds =
new
DataSet();
oledbda.Fill(ds,
"[sheet2$]"
);
con.Close();
dt = ds.Tables[
"[sheet2$]"
];
int
i = 0;
for
(i = 0; i <= dt.Rows.Count - 1; i++)
{
comboBox4.Items.Add(dt.Rows[i].ItemArray[1]);
}
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message);
}
I can get data from Excel 2007 xlsx file but cannot assign default value --select-- with selected value 0
How to do that if possible
Reply
Answers (
3
)
get text between two words in a string
Error When Sending Mail With Asp.net C#