Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All

I created a listview in which items along with checkboxes are created Dynamically.

Now when items and checkboxes are created then I want to fire event for checkbox(which give the checked state of current checkbox)

I Didnt Find event for that

yes I want to fire checked event on checking.

Actually I select a pArticular user from combobox and on that selected item I show three list boxes along with items.

private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            String TabName, TabCaption, GroupName, GroupCaption, ItemName, ItemCaption, ControlName, ControlCaption;
            string username = cmbauthority.SelectedItem.ToString();
            //Extarct User ID
            UserDao autodao = new UserDao();
            User authuser = autodao.selctid_accname(username);
            int Useridd = authuser.Id;
            //Extracts Tabs
            UserTabDao uTdao21 = new UserTabDao();
            DataSet UTds11 = uTdao21.Select_TabID(Useridd);
            
            TabDao tabdao21 = new TabDao();
            DataSet datset2 = new DataSet();
            string name, caption;
            for (int l = 0; l < UTds11.Tables[0].Rows.Count; l++)
            {
                int tabidd11 = Convert.ToInt32(UTds11.Tables[0].Rows[l][0]);
                bool active = Convert.ToBoolean(UTds11.Tables[0].Rows[l][1]);
                //Extract name,caption from tab master   
                datset2 = tabdao21.select_acctabid(tabidd11);
                name = Convert.ToString(datset2.Tables[0].Rows[0][0]);
                caption = datset2.Tables[0].Rows[0][1].ToString();
                // this.listView1.Items.Add(name, caption).;
                if (active == true)
                {
                    this.listView1.Items.Add(name, caption).Checked = true;
                    //Extract Groups
                    GroupDao gpdao = new GroupDao();
                    DataSet dsg1 = gpdao.selectgpid(Useridd, tabidd11);
                    int gpidd;
                    DataSet fds = new DataSet();
                    for (int h = 0; h < dsg1.Tables[0].Rows.Count; h++)
                    {
                        gpidd = Convert.ToInt32(dsg1.Tables[0].Rows[h][0]);
                        bool activestate = Convert.ToBoolean(dsg1.Tables[0].Rows[h][1]);
                        DataSet gpu = gpdao.selectnameall(gpidd);
                        string gname, gcaption;
                        for (int r = 0; r < gpu.Tables[0].Rows.Count; r++)
                        {
                            gname = gpu.Tables[0].Rows[r][0].ToString();
                            gcaption = gpu.Tables[0].Rows[r][1].ToString();
                            if (activestate == true)
                            {
                                this.listView2.Items.Add(gname, gcaption).Checked = true;
                                UserControlDao usdao = new UserControlDao();
                                DataSet ds45 = usdao.slectitemsfromcontrols(Useridd, gpidd);
                                int controlid;
                                ControlsDao cdao09 = new ControlsDao();
                                DataSet ds54 = new DataSet();
                                for (int y = 0; y < ds45.Tables[0].Rows.Count; y++)
                                {
                                    controlid = Convert.ToInt32(ds45.Tables[0].Rows[y][0]);
                                    bool checkforactive = Convert.ToBoolean(ds45.Tables[0].Rows[y][1]);
                                    ds54 = cdao09.selectnamecontorls(controlid);
                                    string cnamerr = ds54.Tables[0].Rows[0][0].ToString();
                                    string ccaption = ds54.Tables[0].Rows[0][1].ToString();
                                    if (checkforactive == true)
                                    {
                                        listView3.Items.Add(cnamerr, ccaption).Checked = true;
                                    }
                                    //else
                                    //{
                                    //    listView3.Items.Add(cnamerr, ccaption).Checked = false;
                                    //}
                                }
                            }
                            else
                            {
                                this.listView2.Items.Add(gname, gcaption).Checked = false;
                            }
                        }
                    }
                }
                else
                {
                    this.listView1.Items.Add(name, caption).Checked = false;
                }
                    
                
            }
        }
Posted
Updated 22-Apr-10 0:27am
v3

1 solution

Very hard to help with so little information.
Can you provide the code for the area you are having problems with?

Also, Am I right in thinking you want the event to launch on the clicking of the check box, rather than on a button event after selection is made?

More help will be possible once you can do these things.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900