CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2016
    Posts
    6

    Checkbox click function

    I have C# form where is public function called 'FormUserEnrol_CheckClick' this function called when checkBox1 or checkBox2 click will open form FormFingerEnrol which working fine, but when I add another checkbox4 or checkbox5 or more nothing happend.

    Please help: bellow code:
    Code:
    public void FormUserEnrol_CheckClick(object sender, EventArgs e)
            {
                CheckBox ckb;
                ckb = sender as CheckBox;
    
                FormFingerEnrol ffe = new FormFingerEnrol();
                if(ffe.ShowDialog()==DialogResult.OK)
                {
                    ckb.Checked = true;
                    if (ckb == checkBox1)
                    {
                        refsize1 = ffe.refsize;
                        ffe.refbuf.CopyTo(refbuf1, 0);
                        fingerbmp1 = ffe.fingerbmp;
                        pbImage1.Image = ffe.fingerbmp;
                    }
                    else if (ckb == checkBox2)
                    {
                        refsize2 = ffe.refsize;
                        ffe.refbuf.CopyTo(refbuf2, 0);
                        fingerbmp2 = ffe.fingerbmp;
                        pbImage2.Image = ffe.fingerbmp;
                    }
    
    	    }	
                else
                {
                    ckb.Checked = false;
                    if (ckb == checkBox1)
                    {
                        refsize1 = 0;
                        fingerbmp1 = null;
                        pbImage1.Image = null;
                    }
                    else if (ckb == checkBox2)
                    {
                        refsize2 = 0;
                        fingerbmp2 = null;
                        pbImage2.Image = null;
                    }
        }
    }
    Last edited by Arjay; April 27th, 2016 at 11:24 AM. Reason: Added code tags

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Checkbox click function

    Quote Originally Posted by kafsar View Post
    but when I add another checkbox4 or checkbox5 or more nothing happend.
    In the code you have usage to checkBox1 and checkBox2, but no usages to checkBox4 and checkBox5. If you want it to work with those, you need to add code to use them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured