예제 #1
0
        public void MethodGetInheritedContextMenuStrip()
        {
            BaseCell c = new BaseCell();

            Assert.AreEqual(null, c.GetInheritedContextMenuStrip(c.RowIndex), "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.HeaderCell = c;
            dgv.Rows.Add(row);

            Assert.AreEqual(null, dgv.Rows[0].HeaderCell.GetInheritedContextMenuStrip(dgv.Rows[0].HeaderCell.RowIndex), "A2");

            ContextMenuStrip cms1 = new ContextMenuStrip();

            cms1.Items.Add("Moose");
            dgv.ContextMenuStrip = cms1;

            Assert.AreSame(cms1, dgv.Rows[0].HeaderCell.GetInheritedContextMenuStrip(dgv.Rows[0].HeaderCell.RowIndex), "A3");

            ContextMenuStrip cms2 = new ContextMenuStrip();

            cms2.Items.Add("Moose");

            dgv.Rows[0].ContextMenuStrip = cms2;
            Assert.AreSame(cms1, dgv.Rows[0].HeaderCell.GetInheritedContextMenuStrip(dgv.Rows[0].HeaderCell.RowIndex), "A4");

            dgv.Rows[0].HeaderCell.ContextMenuStrip = cms2;
            Assert.AreSame(cms2, dgv.Rows[0].HeaderCell.GetInheritedContextMenuStrip(dgv.Rows[0].HeaderCell.RowIndex), "A5");
        }
예제 #2
0
		public void MethodGetInheritedContextMenuStrip ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (null, c.GetInheritedContextMenuStrip (c.RowIndex), "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (null, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A2");

			ContextMenuStrip cms1 = new ContextMenuStrip ();
			cms1.Items.Add ("Moose");
			dgv.ContextMenuStrip = cms1;

			Assert.AreSame (cms1, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A3");

			ContextMenuStrip cms2 = new ContextMenuStrip ();
			cms2.Items.Add ("Moose");
			dgv.Columns[0].ContextMenuStrip = cms2;

			Assert.AreSame (cms2, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A4");

			dgv.Rows[0].ContextMenuStrip = cms1;
			Assert.AreSame (cms1, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A5");

			dgv.Rows[0].Cells[0].ContextMenuStrip = cms2;
			Assert.AreSame (cms2, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A6");
		}