0

どうすればdatagridview列を変更できますwidthか? 次の方法を試しましたが、うまくいきません。なぜ変わらないのですか?

  string[] strArrDoctor = new string[] {"ID", "Name", "Specialization", "Contact No", "Experience(Years)", "Delete" };
           //strin of array which contains Patient table columns names
            string[] strArrPatient = new string[] {"ID", "Name", "Join Date", "Ailment", "Doctor ID", "Delete" };
            if (rBtnDoctor.Checked)
            {
                for (int intIndex = 0; intIndex < dgvShowRecords.Columns.Count; intIndex++)
                {
                    //assigning Column names with our specified String of arrays
                    dgvShowRecords.Columns[intIndex].HeaderText = strArrDoctor[intIndex];
                }
            }
            else
            {
                for (int intIndex = 0; intIndex < dgvShowRecords.Columns.Count;      intIndex++)
                {
                    dgvShowRecords.Columns[intIndex].HeaderText=strArrPatient[intIndex];
                }
            }
            //dgvShowRecords is Datagridview Name
            dgvShowRecords.Columns["Name"].Resizable = DataGridViewTriState.True;
            dgvShowRecords.Columns["Name"].Width = 200;
            dgvShowRecords.Columns["ID"].Width = 20;

変更されていない理由を知っている人は教えてください。

ここに画像の説明を入力

4

1 に答える 1

4

試す:

dgvShowRecords.AutoResizeColumns();
于 2012-11-07T13:18:14.660 に答える