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
anna john
NA
47
9k
allow combobox to add user defined values at runtime
Oct 9 2019 11:23 AM
i have a combobox column[category] in my datagridview. the category column in datagridview shows values from a table. i want the combobox to add user defined values at run time and save it into database and show in combobox also.
i have the basic code to show data in the table to the combobox. can someone please guide me on how to accept user input and add it to database and combobox .
void
populatecategorycombobox()
{
using
(OleDbConnection Connection =
new
OleDbConnection(connectionString))
{
Connection.Open();
OleDbDataAdapter sqlDa =
new
OleDbDataAdapter(
"SELECT * from category"
, Connection);
DataTable dtbl =
new
DataTable();
sqlDa.Fill(dtbl);
cbxcategory.ValueMember =
"catid"
;
cbxcategory.DisplayMember =
"catname"
;
DataRow topItem = dtbl.NewRow();
topItem[0] = 0;
topItem[1] =
"-Select-"
;
dtbl.Rows.InsertAt(topItem, 0);
cbxcategory.DataSource = dtbl;
}
}
Reply
Answers (
5
)
pls help on datagrid view insert /update operation
event to validate datagridview rows