1

150% に設定されたディスプレイ設定 (Windows 7) で動作するようにしようとしているこのフォームがあります。 ここに画像の説明を入力

「myTableAdapter.Fill();」をコメントアウトすると、それがわかりました。それは完全に正常に動作します。

private void Form_Load(object sender, EventArgs e)
    {
        //myTableAdapter.Fill(myDatabaseDataSet.myaccessdatabase);
    }

ここに画像の説明を入力

問題は、「myTableAdapter.Fill();」が必要なことです。コンボボックスに追加されるアイテムのリストを取得できるようにするためにロードしますが、テーブルアダプターがロードされると、少し制御不能になります (フォントのサイズと場所が異なります)。 ここに画像の説明を入力

これは、画面の左上隅に表示されるコンボボックスに関する既知の問題ではなく、datagridview の読み込み時に発生する問題であることはわかっています。これは、表示フォント サイズが 150% に設定されている場合にのみ発生します。

これは私のコードです:

 private void Form_Load(object sender, EventArgs e)
    {
        myTableAdapter.Fill(myDatabaseDataSet.MyAccessDatabase);

        //fixes the bug that makes the dropdown menus to pop up in the left
        //corner of the screen. This sample if repeats for each 
        //individual combobox...

        var item1 = toolStripComboBox1;
        var createControl1 = item1.Control.Parent.GetType().GetMethod("CreateControl", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
        createControl1.Invoke(item1.Control.Parent, new object[] { true });

             //combobox menustrip code to populate the list of names
             //coming from the access database (in this case for        
             //Managers). It is the same code for "Buyer"; "XP" 
             //and "Aging"...
             for (int intCount = 0; intCount < myDatabaseDataSet.Tables[0].Rows.Count; intCount++)
        {
            var val = myDatabaseDataSet.Tables[0].Rows[intCount][0].ToString();
            if (!toolStripComboBox1.Items.Contains(val))
            {
                toolStripComboBox1.Items.Add(val);
            }
        }
  }

繰り返しますが、これは、表示フォントが他のパーセンテージに設定されている場合には発生しません。私の理論の 1 つは、コンボ ボックスが暴走しないように、コードのこの部分を微調整する必要があるかもしれないというものです。

for (int intCount = 0; intCount < myDatabaseDataSet.Tables[0].Rows.Count; intCount++)
        {
            var val = myDatabaseDataSet.Tables[0].Rows[intCount][0].ToString();
            if (!toolStripComboBox1.Items.Contains(val))
            {
                toolStripComboBox1.Items.Add(val);
            }
        }

このレンダリングの問題を回避できるコンボボックス項目をロードする別の方法はありますか?

4

0 に答える 0