http://files.cnblogs.com/xe2011/officetable.rar

画表格防OFFICE的功能


画表格的功能

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
 
namespace System.Windows.Forms
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        public int x = 0;
        public int y = 0;
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            for (int i = 0; i < 8; i++)//i是横着的
            {
                for (int j = 0; j < 7; j++) //j是竖着的
                {
                    Rectangle boxRect = new Rectangle(1 + 20 * i, 1 + j * 20, 18, 18);
                    e.Graphics.FillRectangle(new SolidBrush(Color.White), boxRect);
                    e.Graphics.DrawRectangle(new Pen(Color.FromArgb(131, 125, 125), 1), boxRect);
                }
            }
        }
 
        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            Rectangle rect1 = new Rectangle(0, 0, e.Location.X, e.Location.Y);
            Text = rect1.ToString();
            Graphics g = panel1.CreateGraphics();
 
            x = (rect1.Width - 2) / 20 + 1;
            y = (rect1.Height - 2) / 20 + 1;
 
            if (e.Location.X == 0 || e.Location.Y == 0 || e.Location.X < 2 || e.Location.Y < 2)
            {
                x = 0;
                y = 0;
            }
 
            if (x > 8)
                x = 8;
 
            if (y > 7)
                y = 7;
 
            labelMsg.Text = string.Format("{0} x {1}", x, y);
 
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    Rectangle rect2 = new Rectangle(1 + 1 + 20 * i, 1 + 1 + j * 20, 17, 17);
 
                    Brush brush1 = new SolidBrush(Color.White);
                    if (rect1.IntersectsWith(rect2))
                        brush1 = new SolidBrush(SystemColors.Highlight);
 
                    g.FillRectangle(brush1, rect2);
                }
            }
 
            g.Dispose();
        }
 
        private void panel1_Click(object sender, EventArgs e)
        {
            string s = string.Format("{0} x {1}", x, y);
            MessageBox.Show(s);
            ((ToolStripDropDown)Parent).Close(); 
        }
    }
}

使用

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
 
 
namespace System.Windows.Forms
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            form1.TopLevel = false;
            host = new ToolStripControlHost(form1);
            host.AutoSize = false;
            host.Width = form1.Width;
 
        }
 
        Form1 form1 = new Form1();
        ToolStripDropDown dropdown = new ToolStripDropDown();
        ToolStripControlHost host ;//= new ToolStripControlHost(form1);
 
        private void button1_MouseEnter(object sender, EventArgs e)
        {
            dropdown.Margin = Padding.Empty;
            dropdown.Padding = Padding.Empty;
            host.Margin = Padding.Empty;
            host.Padding = Padding.Empty;
 
 
            dropdown.Items.Add(host);
            // 让这个窗体出面在按扭的相对下面
            Point location = PointToScreen(button1.Location);
            dropdown.Show(location.X, location.Y + button1.Height); 
        }
    }
}

画表格防OFFICE的功能的更多相关文章

  1. 电脑如何防蹭网?使用防蹭网功能杜绝未知设备连接WiFi

    发布时间:2015-09-27 15:24发布者:系统城-shaojing浏览数:733 网络越来越卡?网页打开越来越慢?如果你有以上疑问,那么就要确认自己是不是被"蹭网"了.尽管 ...

  2. Winform系列——好用的DataGridview过滤控件(表格的高级搜索功能)

    上一篇 Winform系列——好看的DataGridView折叠控件 中主要介绍了DataGridview的表格多级折叠功能.这章主要介绍下最近封装的另一个DataGridview表格高级过滤的功能. ...

  3. Android系统更新防互刷功能实现与分析【转】

    本文转载自:https://blog.csdn.net/huangyabin001/article/details/44465145 版权声明:本文为博主原创文章,未经博主允许不得转载.    htt ...

  4. jquery-easyui 中表格的行编辑功能

    具体实现代码如下: <table id="tt"></table> $('#tt').datagrid({ title:'Editable DataGrid ...

  5. 三种扩展 Office 软件功能的开发模型对比 – Office Add-In Model, VBA 和 VSTO

    当 Office 用户需要针对文档自定义新功能时,可以求助于 VBA 或者 VSTO 两种方式.Office 2013 富客户端以后,微软为 Office 平台上的开发者提供了一种新模型 --- Of ...

  6. Java 从零开始实现一个画图板、以及图像处理功能,代码可复现

    Java 从零开始实现一个画图板.以及图像处理功能,代码可复现 这是一个学习分享博客,带你从零开始实现一个画图板.图像处理的小项目,为了降低阅读难度,本博客将画图板的一步步迭代优化过程展示给读者,篇幅 ...

  7. C算法编程题(三)画表格

    前言 上一篇<C算法编程题(二)正螺旋> 写东西前还是喜欢吐槽点东西,要不然写的真还没意思,一直的想法是在博客园把自己上学和工作时候整理的东西写出来和大家分享,就像前面写的<T-Sq ...

  8. jQuery treetable【表格多重折叠树功能及拖放表格子元素重新排列】

    今天有个表格需求做到多重折叠子元素功能,仔细想了下实现原理, 1.在html中,把父子节点的关系写在自定义属性,但对于节点是否有孩子(hasChild),是否是最后一个节点(isLastOne),是否 ...

  9. 关于ligerui 中 grid 表格的扩展搜索功能在远程数据加载时无法使用的解决办法

    要想使用grid里的扩展搜索功能,除了要引用ligerui主要的js文件外,还必须引入下面的JS文件: 1.Source\demos\filter\ligerGrid.showFilter.js 2. ...

随机推荐

  1. 关闭 VS的实时调试器

    可以这样关闭: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger HKEY_LOCAL_ ...

  2. SharePoint 2010 使用自定义aspx页面替换列表默认的新建(NewForm.aspx),查看(DispForm.aspx)和编辑(EditForm.aspx)页面

    转:http://www.cnblogs.com/sygwin/archive/2011/11/04/2236678.html 如何使用自定义的aspx页(比如Application Page)替换列 ...

  3. Apache Mina原理及典型例子分析

    Apache Mina ,一个高性能 Java 异步并发网络通讯框架.利用 Mina 可以高效地完成以下任务: TCP/IP 和 UDP/IP 通讯 串口通讯 VM 间的管道通讯 SSL/TLS JX ...

  4. JSP文件上传代码

    一.首先建立一个上传的界面,取名为a.jsp,代码如下 <%@ page contentType="text/html; charset=utf-8" language=&q ...

  5. C语言基础--结构体对齐,位域,联合体

    结构体对齐 1--结构体对齐的原因与意义 许多计算机系统对基本数据类型的可允许地址做出了一些限制,要求某种类型的对象的地址必须是某个值K(通常是2,4,8)的倍数,而这个k则被称为该数据类型的对齐模数 ...

  6. Good Bye 2015 C - New Year and Domino

    题意:计算给定矩形面积(r1,c1),(r2,c2)内长度为2的有多少个?向右或向下计算. 思路:预处理字符.分别向右和向下处理.注意边界情况,可能算多了.用容斥原理计算长度为二的单位. #inclu ...

  7. 题目1096:日期差值(a-b=(a-c)-(b-c))

    http://ac.jobdu.com/problem.php?pid=1096 题目描述: 有两个日期,求两个日期之间的天数,如果两个日期是连续的我们规定他们之间的天数为两天 输入: 有多组数据,每 ...

  8. 【VMware虚拟机】【克隆问题】在VMware 9.0下克隆CentOS6.5虚拟机无法识别eth网卡

    [日期]2014年4月23日 [平台]windows 8 vmware workstation 9.0 centos 6.5 [日志]1)执行ifconfig命令,输出: 2)查看/etc/udev/ ...

  9. 编译vo-aacenc遇到的问题

    sourceforge更新了vo-aacenc到0.1.3,就把自己的编码器也更新到最新.编译过程中无聊多测试了一下 发现一个小问题http://sourceforge.net/projects/op ...

  10. ERROR: transport error 202: bind failed: Address already in use

    早上上班,同事反应服务上不去,后台看了一下,发现tomcat挂掉了,重新启动tomcat时报错. ERROR: transport error 202: bind failed: Address al ...