Jump to content

Datagrid Checkbox Columns


korasoglu
 Share

Recommended Posts

            string isimler = string.Empty;

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[0].Value) == true)
                {
                    string isim = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    isimler += isim + Environment.NewLine;
                }
            }

            MessageBox.Show("Seçilen isimler:\n" + isimler);

Please register to see this content.

  • Like 1
Link to comment
Share on other sites

ArrayList aa = new ArrayList();
             foreach (DataGridViewRow row in dataGridView1.Rows)
             {
                 if (Convert.ToBoolean(row.Cells[0].Value) == true)
                 {
                     //rows_with_checked_column.Add(row);
                     aa.Add(row.Index);
                 }
             }

Kaç seçim yaptıysam bir eksik görüyor birde bunu deniyelim

Link to comment
Share on other sites

Hocam Hala bende bir eksik görüyor

ArrayList aa = new ArrayList(); aa.Clear();
             for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    tik++;
                    if (Convert.ToBoolean(dataGridView1.Rows.Cells[10].Value) == true)
                    {
                        string isim = dataGridView1.Rows.Cells[0].Value.ToString();
                        aa.Add(i);
                        
                    }
                }
             MessageBox.Show( aa.Count.ToString());

Link to comment
Share on other sites

hocam şöyle oldu

 

ArrayList secim = new ArrayList();
        private void dataGridView1_CellContentClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
        {

            DataGridViewCheckBoxCell ch1 = new DataGridViewCheckBoxCell();
            ch1 = (DataGridViewCheckBoxCell)dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[10];

            if (ch1.Value == null)
                ch1.Value = false;
            switch (ch1.Value.ToString())
            {
                case "True":
                    secim.Remove(dataGridView1.CurrentRow.Index);
                    ch1.Value = false;
                    
                    break;
                case "False":
                    secim.Add(dataGridView1.CurrentRow.Index);
                    ch1.Value = true;
                    
                    break;
            }
            
        }

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...