C#日历样式的下拉式计算器实例讲解

2019-12-26 13:38:30王冬梅
  • //Add the host to the list   this.Items.Add(this.drop);  
  • }   } 

    在按钮的单击事件中添加以下代码:

     

     
    1. private void button1_Click(object sender, EventArgs e)   {  
    2. CalculatorControl calculator = new CalculatorControl();   CalDrop cal = new CalDrop(calculator);  
    3.   Point controlLoc = fm.PointToScreen(button1.Location);  
    4. Point relativeLoc = new Point(controlLoc.X + button1.Width + 100,   controlLoc.Y + button1.Height * 2);  
    5. Rectangle calRect = button1.DisplayRectangle;   cal.Show(locPoint);  
    6. }  

    添加控件到DataGridViewCell

    在你构建解决方案时,新的按钮控件会出现在工具箱中。添加以下代码到项目的窗体类中。