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. bzoj1029

    贪心,比较明显了(很像USACO的风格); 按时间限制排序(升序) 顺次处理,如果当前时间能够修复就修复 否则就在之前修复的任务中找一个耗时最多(大于当前任务)的,改成修当前任务; 显然这样最优吧, ...

  2. 对于requirejs AMD模块加载的理解

    个人人为使用模块化加载的优点有三: 1,以我的项目为例:90%为图表展示,使用的是echarts,此文件较大,requirejs可以在同一个版本号(urlArgs)之下缓存文件,那么我就可以在访问登陆 ...

  3. C#控件背景透明的几种解决方案

    已经很少做winform程序了,最新参与了一个小项目,遇到了控件背景透明的功能要求,特在此总结一下,供有需要的同行参考. 0.背景透明的概念和分类 背景透明是啥意思呢,就是背景透明.哈哈,废话了.其实 ...

  4. 对 Azure 虚拟网络网关的改进

    YU-SHUN WANG Azure 网络高级项目经理 在 2014 年欧洲 TechEd 大会上,我们宣布了对Azure 虚拟网络网关的多项改进: 1.  高性能网关 SKU 2.  Azure 虚 ...

  5. Java [leetcode 33]Search in Rotated Sorted Array

    题目描述: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 ...

  6. 异常处理 Exception

    一.异常类 1.在C#中所有的异常都是使用一个异常类型的示例对象表示的,这些异常类型都是继承自System.Exception类型,或者直接使用System.Exception类型的实例对象: 2.在 ...

  7. 序列化类型为XX的对象时检测到循环引用

    /// 产品列表展示 /// </summary> /// <returns></returns> ) { //获得所有组别 Galasys_IBLL.IT_BIZ ...

  8. mkimage工具 加载地址和入口地址 内核启动分析

    第三章第二节 mkimage工具制作Linux内核的压缩镜像文件,需要使用到mkimage工具.mkimage这个工具位于u-boot-2013. 04中的tools目录下,它可以用来制作不压缩或者压 ...

  9. 那些年一起踩过的坑 — Date类型序列化的问题

      坑在哪里?        序列化 和 反序列化 的时候对Date字段的格式设置不一致        例如:将Java bean序列化成Json string的时候 格式为 yyyy-MM-dd 解 ...

  10. ie 提示浏览器升级信息 干掉ie

    <!--[]> <div id=</a> 或以下浏览器: <a href="http://www.mozillaonline.com/"> ...