예제 #1
0
        private void Btn_AjouterClient_Click(object sender, EventArgs e)
        {
            p_client.Controls.Clear();
            GS_Client ADDClient = new GS_Client()
            {
                Dock = DockStyle.Fill, TopLevel = false, TopMost = false
            };

            p_client.Controls.Add(ADDClient);
            ADDClient.Show();
        }
예제 #2
0
        private void Btn_ModifierClient_Click(object sender, EventArgs e)
        {
            row1 = new DataGridView();
            if (ListClient.g_listClient.SelectedRows.Count != 1)
            {
                MessageBox.Show("select client");
            }
            else
            {
                // Set up a List<T> to hold the indexes of the visible columns
                List <int> visibleColumns = new List <int>();
                //int j = 0; j < dataGridView1.Columns.Count; j++DataGridViewColumn col in ListClient.g_listClient.Columns
                for (int j = 0; j < ListClient.g_listClient.Columns.Count; j++)
                {
                    if (ListClient.g_listClient.Columns[j].Visible)
                    {
                        row1.Columns.Add((DataGridViewColumn)ListClient.g_listClient.Columns[j].Clone());

                        visibleColumns.Add(ListClient.g_listClient.Columns[j].Index);
                    }
                }

                // Now add the data from the columns
                // Set a counter for the current row index for the second DataGridView
                int rowIndex = 0;
                row1.Rows.Clear();
                row1.Refresh();

                foreach (DataGridViewRow row in ListClient.g_listClient.SelectedRows)
                {
                    // Add a new row to the DataGridView
                    //row1.Rows.Add();

                    // Loop through the visible columns
                    for (int i = 0; i < visibleColumns.Count; i++)
                    {
                        // Use the index of the for loop for the column in the target data grid
                        // Use the index value from the List<T> for the cell of the source target data grid
                        row1.Rows[rowIndex].Cells[i].Value = row.Cells[visibleColumns[i]].Value;
                    }

                    // Increment the rowIndex
                    rowIndex++;
                }

                p_client.Controls.Clear();
                GS_Client UPDATEClient = new GS_Client()
                {
                    Dock = DockStyle.Fill, TopLevel = false, TopMost = false
                };
                p_client.Controls.Add(UPDATEClient);
                UPDATEClient.Show();
            }
        }