'

alswlek의 이미지
shint의 이미지

//---------------------------------------------------------------
// 체크박스 개수만큼 배열을 생성
//---------------------------------------------------------------
CheckBox[] boxes = new CheckBox[50];
 
 
public FrmSelectSeat6()
{
	InitializeComponent();
}
 
private void Form6_Load(object sender, EventArgs e)
{
 
}
 
private void button2_Click(object sender, EventArgs e)
{
	for (int i=0; i<50; i++)
	{
		boxes[i].Checked = true;
	}
 
	CheckBox[] count;
	for(int z=0; z<50; z++)
	{
		count[z] = new CheckBox();
	}
 
	count[ 0] = checkBox0 ;  count[ 1] = checkBox1 ;  count[ 2] = checkBox2 ;  count[ 3] = checkBox3 ;  count[ 4] = checkBox4 ;
	count[ 5] = checkBox5 ;  count[ 6] = checkBox6 ;  count[ 7] = checkBox7 ;  count[ 8] = checkBox8 ;  count[ 9] = checkBox9 ;
	count[10] = checkBox10;  count[11] = checkBox11;  count[12] = checkBox12;  count[13] = checkBox13;  count[14] = checkBox14;
	count[15] = checkBox15;  count[16] = checkBox16;  count[17] = checkBox17;  count[18] = checkBox18;  count[19] = checkBox19;
	count[20] = checkBox20;  count[21] = checkBox21;  count[22] = checkBox22;  count[23] = checkBox23;  count[24] = checkBox24;
	count[25] = checkBox25;  count[26] = checkBox26;  count[27] = checkBox27;  count[28] = checkBox28;  count[29] = checkBox29;
	count[30] = checkBox30;  count[31] = checkBox31;  count[32] = checkBox32;  count[33] = checkBox33;  count[34] = checkBox34;
	count[35] = checkBox35;  count[36] = checkBox36;  count[37] = checkBox37;  count[38] = checkBox38;  count[39] = checkBox39;
	count[40] = checkBox40;  count[41] = checkBox41;  count[42] = checkBox42;  count[43] = checkBox43;  count[44] = checkBox44;
	count[45] = checkBox45;  count[46] = checkBox46;  count[47] = checkBox47;  count[48] = checkBox48;  count[49] = checkBox49;
 
	for (int j=0; j<50; j++)
	{
		if(boxes[j].Checked == count[j].Checked)
		{
			MessageBox.Show("으악!");
			count[j].Enabled = false;
		}
	}

#if 0
http://blog.naver.com/krinlion?Redirect=Log&logNo=40127184606
① 그룹박스의 모든 컨트롤들을 Control클래스 자료형 ctl에 넣는다
② 그룹박스 내 모든 컨트롤 중 CheckBox이면서
그 이름이 항목으로 시작하는 컨트롤들이면 참이다
③ ctl이 Control형 클래스이기 때문에 CheckBox형태로 형변환 시켜준다
형변환에는 2가지 방법이 있는데 cast형변환을 해도 되고
'부모형객체명 as 자식형클래스"처럼 as를 이용해서 할 수 있다.
④ 속성이 checked되어 있는 지 확인한다.
#endif

private void btn확인_Click(object sender, EventArgs e)
{
         foreach (Control ctl in this.gpb선택항목.Controls)                //①
        {
                if(ctl is CheckBox && ctl.Text.StartsWith("항목"))        //②
                {
                        CheckBox box=ctl as CheckBox;                        //③CheckBox box=(CheckBox)ctl;③as연산자
                        if(box.Checked)                                                //④
                            this.lblResult.Text+=ctl.Text+"/";
                }
        }
	}

c# foreach CheckBox
http://blog.naver.com/krinlion?Redirect=Log&logNo=40127184606

http://blog.naver.com/c1004mj/60097786535

c# foreach CheckBox
http://www.google.co.kr/search?hl=ko&source=hp&biw=&bih=&q=c%23+foreach+CheckBox&gbv=2&oq=c%23+foreach+CheckBox&gs_l=heirloom-hp.12..0l2j0i30l6j0i8i30j0i5i30.994.994.0.8470.1.1.0.0.0.0.172.172.0j1.1.0....0...1ac..34.heirloom-hp..0.1.171.IZNCpPa_a5E

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

alswlek의 이미지

와 ㅎㅎㅎ 드디어 매번 고민하다 도움을 받아 풀게되었네요 ㅠㅠ

감사합니다 ㅠㅠ

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.