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. 网站开发中的相对URL问题--JSP

    问题描述: 入门网站开发时,我们会在相对URL问题上有疑惑.例如,在一个jsp页面中引入css外部文件, <link rel="stylesheet"          hr ...

  2. Java web 项目 tomcat部署方式.

    本地做Java Web项目的时候常常会用到tomcat部署测试的问题, 这里介绍项目的部署方法: 1,配置文件的形式: 例如: 你的项目目录为:f:\workspaces\MyProject,此时使用 ...

  3. BZOJ_2434_[NOI2011]_阿狸的打字机_(AC自动机+dfs序+树状数组)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=2434 给出\(n\)个字符串,\(m\)个询问,对于第\(i\)个询问,求第\(x_i\)个字 ...

  4. HAOI2011 problem b

    2301: [HAOI2011]Problem b Time Limit: 50 Sec  Memory Limit: 256 MBSubmit: 1047  Solved: 434[Submit][ ...

  5. android studio 安装总结

    Android Studio 的安装和配置篇(Windows篇<转> http://www.jianshu.com/p/fc03942548cc# 中间gradle下载比较慢:解决方法 需 ...

  6. SharePoint 2010 master page 控件介绍(4):隐藏placeholder

    转:http://blog.csdn.net/lgm97/article/details/6409225 <!-- form digest  安全控件用来进行form的安全校验--> &l ...

  7. c#中单元测试

    从走进.net后发现每天有写不完的代码,有做不完的测试...人感觉都已经机械,我们需要认清自己调整好心态,问下自己是否真的喜欢编程.我的答案当然也就是我爱编码,编码给我带来了许多欢乐,每天都给我体验小 ...

  8. Iterator和ListIterator区别

    我们在使用List,Set的时候,为了实现对其数据的遍历,我们经常使用到了Iterator(迭代器).使用迭代器,你不需要干涉其遍历的过程,只需要每次取出一个你想要的数据进行处理就可以了. 但是在使用 ...

  9. WSGI和PASTE

    WSGI就是一个标准,WSGI server就是实现了这个标准的一个容器.这个标准类似于如下的东东: 1 2 3 4 5 6 7 8 9 10 11 from wsgiref.simple_serve ...

  10. Guide to make CentOS 7 the perfect desktop

    原文地址:  http://www.dedoimedo.com/computers/fedora-pimp.html My original review of CentOS 7 was less e ...