Lookupedit add and remove items ?

Lookupedit add and remove items ?

Old forum URL: forums.lhotka.net/forums/t/12595.aspx


dong posted on Wednesday, April 23, 2014

Can Lookupedit add and remove each item ?

ajj3085 replied on Wednesday, April 23, 2014

dong
Can Lookupedit add and remove each item ?

I think we need a bit more context to answer your question?

dong replied on Wednesday, April 23, 2014

I add each Item (record) into Lookupedit but an error

                // Open connection database

                Cnn.ConnectSQL();   

               SqlDataAdapter da = new SqlDataAdapter("SELECT TabSTAFF.IDSTAFF, TabSTAFF.NAMESTAFF FROM TabSTAFF ORDER BY TabSTAFF.IDSTAFF;", Cnn.objConnect);

                DataSet ds = new DataSet();    

                DataTable dt = new DataTable();

                da.Fill(ds, "TabSTAFF");                         

                dt = ds.Tables["TabSTAFF"];

 

                kpNhanvien.EditValue = dt.Rows[0]["NAMESTAFF"].ToString();

                foreach (DataRow dr in dt.Rows)

                {

                      / / Get an error immediately below this line

                      lkpNhanvien.Properties.Columns.Add(new LookUpColumnInfo(dr["IDSTAFF"].ToString(), dr["NAMESTAFF"].ToString()));                    

 

                }

                //lkpQuyensd.Properties.DataSource = dt;

                lkpNhanvien.Properties.DisplayMember = "NameStaff";

                lkpNhanvien.Properties.ValueMember = "IDstaff";

 

And I want to remove each item in Lookupedit ? how to write code looupedit ?

Copyright (c) Marimer LLC