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. Mongodb的范式化和反范式化

    如果是涉及到一对多的数据格式,可使用文档引用范式化数据. 在一个,User对象中,如果涉及到工作信息或者联系地址的,这些信息会频繁的进行访问,可使用嵌入式文档对数据进行反范式化.

  2. C#调用Geocoding API进行地理编码与逆编码

    使用C#调用Geocoding API来将地址转为经纬度,或者将经纬度转变为具体的地址. Geocoding API的详细介绍参见:http://developer.baidu.com/map/web ...

  3. Java泛型类与类型擦除

    转载自:http://blog.csdn.net/lonelyroamer/article/details/7868820 一.Java泛型的实现方法:类型擦除 前面已经说了,Java的泛型是伪泛型. ...

  4. 【转】基于Android Fragment功能的例子

    原文网址:http://blog.csdn.net/eyu8874521/article/details/8252216 通过最近空闲时候对Fragment的学习,尝试着写了一个小Demo,将在开发的 ...

  5. 也用 Log4Net 之将日志记录到数据库的后台实现 (二)

    也用 Log4Net 之将日志记录到数据库的后台实现 (二)  大家下午好,昨天讲了配置,今天我们讲讲后台实现,在完成了后台实现后,我们才能真正意义上的解决把自定义属性字段值录入到数据库中. 在开写之 ...

  6. [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.2.10

    (1). The numerical radius defines a norm on $\scrL(\scrH)$. (2). $w(UAU^*)=w(A)$ for all $U\in \U(n) ...

  7. UVA 10462 Is There A Second Way Left? 次小生成树

    模板题 #include <iostream> #include <algorithm> #include <cstdio> #include <cstdli ...

  8. mac中viso的兼容工具

    http://www.orsoon.com/Mac/77738.html破解教程 http://www.pc6.com/mac/111747.html下载地址 很强大,很爽.

  9. 进入IT行业,你后悔过吗?

    问:你曾后悔进入 IT 行业吗?为什么? 也许你后悔做了IT,但是很希望你能用自己混IT界的惨痛经历给题主这样的后来人提个醒. 也许你庆幸做了IT,同样很希望能够看到同行朋友们的真诚交流. miao ...

  10. SSDT Hook结构

    目录 SSDT Hook效果图 SSDT简介 SSDT结构 SSDT HOOK原理 Hook前准备 如何获得SSDT中函数的地址呢 SSDT Hook流程 SSDT Hook实现进程保护 Ring3与 ...