本人开发的开发者技术变现资源聚集地,大家支持下,下面是网址

https://www.baiydu.com

该控件的主要实现思路是用的objective-c中的自定义控件思路,主视图中放子视图

效果图

 (窗体调用代码)
public partial class Form1 : RibbonForm
{
List<Panel> arrayPanel = new List<Panel>();
List<Panel> arrayPanel1 = new List<Panel>();
List<LabelControl> detailButtonArray = new List<LabelControl>();
public Form1()
{ for (int i = 0; i < 30; i++)
{ string NoticeTitle = "自定义ScrollbarList控件";
string PublishData = "2014-6-3";
Panel tempPanel = new Panel();
tempPanel.Height = 25;
tempPanel.Width = 330;
LabelControl noticeTitleLabel = new LabelControl();
noticeTitleLabel.Text = NoticeTitle;
noticeTitleLabel.ForeColor = Color.FromArgb(22, 66, 139);
noticeTitleLabel.Location = new Point(5, 5);
tempPanel.Controls.Add(noticeTitleLabel );
LabelControl noticePublishDataLabel = new LabelControl();
noticePublishDataLabel.ForeColor = Color.FromArgb(22, 66, 139);
noticePublishDataLabel.Text = PublishData;
noticePublishDataLabel.Location = new Point(200, 5);
tempPanel.Controls.Add(noticePublishDataLabel);
LabelControl detialInfoButton = new LabelControl();
detialInfoButton.Location = new Point(290,5);
//detialInfoButton.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple;
detialInfoButton.Text = "查看";
detialInfoButton.ForeColor = Color.FromArgb(22, 66, 139);
detialInfoButton.Click += pannelClick;
detailButtonArray.Add(detialInfoButton);
tempPanel.Controls.Add(detialInfoButton);
tempPanel.Location = new Point(5, i * 25 + i * 5);
arrayPanel.Add(tempPanel);
} for (int i = 0; i < 10; i++)
{ string NoticeTitle = "自定义ScrollbarList控件";
string PublishData = "2014-6-3";
Panel tempPanel = new Panel();
tempPanel.Height = 25;
tempPanel.Width = 330;
LabelControl noticeTitleLabel = new LabelControl();
noticeTitleLabel.Text = NoticeTitle;
noticeTitleLabel.ForeColor = Color.FromArgb(22, 66, 139);
noticeTitleLabel.Location = new Point(5, 5);
tempPanel.Controls.Add(noticeTitleLabel);
LabelControl noticePublishDataLabel = new LabelControl();
noticePublishDataLabel.ForeColor = Color.FromArgb(22, 66, 139);
noticePublishDataLabel.Text = PublishData;
noticePublishDataLabel.Location = new Point(200, 5);
tempPanel.Controls.Add(noticePublishDataLabel);
LabelControl detialInfoButton = new LabelControl();
detialInfoButton.Location = new Point(290, 5);
//detialInfoButton.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple;
detialInfoButton.Text = "查看";
detialInfoButton.ForeColor = Color.FromArgb(22, 66, 139);
detialInfoButton.Click += pannelClick;
detailButtonArray.Add(detialInfoButton);
tempPanel.Controls.Add(detialInfoButton);
tempPanel.Location = new Point(5, i * 25 + i * 5);
arrayPanel1.Add(tempPanel);
}
InitializeComponent();
InitSkinGallery();
InitGrid(); this.noticeControl1.tempMasterPanel = arrayPanel;
this.noticeControl1.bindSource();
this.noticeControl1.NoticeTitle = "最新供应信息";
this.noticeControl1.setTitle(); this.noticeControl2.tempMasterPanel = arrayPanel1;
this.noticeControl2.bindSource();
this.noticeControl2.NoticeTitle = "最新求购信息";
this.noticeControl2.setTitle(); }
/// <summary>
/// 列表中最后一列按钮绑定的CLICK事件(为了好看一点,这按钮用的是LABEL标签)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void pannelClick(object sender, EventArgs e)
{
foreach (LabelControl contronl in detailButtonArray)
{
if (contronl == sender)
{
(这个弹出框也是用WINFORM窗体重写过的,就不发布出来了)
CustomContronl.AlertForm AlertForm = new CustomContronl.AlertForm("hihihi!!!"); AlertForm.ShowDialog();
}
}
}

  

(自定义控件代码)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections; namespace DXApplication14.CustomContronl
{
public partial class noticeControl : UserControl
{
VScrollBar vScrollBar1 = new VScrollBar();
Panel contentPannel = new Panel();
public string NoticeTitle { get; set; }
public List<Panel> tempMasterPanel { get; set; } public int CrrentValue = 0;
int changeValue = 0;
public noticeControl()
{
vScrollBar1.Scroll += new ScrollEventHandler(
this.vScrollBar1_Scroll);
vScrollBar1.ValueChanged += new EventHandler(
this.vScrollBar1_ValueChanged);
InitializeComponent();
vScrollBar1.Location = new Point(290, 25);
vScrollBar1.Height = 300;
Controls.Add(vScrollBar1); } public void setTitle()
{
this.labelControl1.Text = NoticeTitle;
}

private void vScrollBar1_ValueChanged(Object sender,
EventArgs e)
{ if (CrrentValue == vScrollBar1.Value)
{
return;
} else
{ changeValue = CrrentValue - vScrollBar1.Value; if (changeValue > 0)
{ foreach (Panel pannel in tempMasterPanel)
{ pannel.Location = new Point(pannel.Location.X, pannel.Location.Y - (changeValue * 25 + changeValue * 5)*-1);
} }
else
{
foreach (Panel pannel in tempMasterPanel)
{ pannel.Location = new Point(pannel.Location.X, pannel.Location.Y + (changeValue * 25 + changeValue * 5));
} } CrrentValue = vScrollBar1.Value;
}
} private void vScrollBar1_Scroll(Object sender,
ScrollEventArgs e)
{ } //给scrollbarList绑定数据的方法
public void bindSource()
{
vScrollBar1.Maximum = tempMasterPanel.Count + 10;
contentPannel.Width = this.Width - 2;
contentPannel.Height = tempMasterPanel.Count * 25 + tempMasterPanel.Count * 5;
contentPannel.Location = new Point(1, 25);
foreach (Panel pannel in tempMasterPanel)
{
contentPannel.Controls.Add(pannel);
} this.Controls.Add(contentPannel);
} }
}

  

本人创业做的一款androidApp, 下载量已经有2000多万,各种当前热门的网络手机奖励红包全部集成,另外还有热门电影和淘宝高额优惠券!很适合各类型的用户。

 

C#Winform VScrollBar+Pannel自定义列表控件(原)的更多相关文章

  1. 在Winform界面使用自定义用户控件及TabelPanel和StackPanel布局控件

    在很多时候,我们做一些非常规化的界面的时候,往往需要创建一些用户控件,在其中绘制好一些基础的界面块,作为后续重复使用的一个单元,用户控件同时也可以封装处理一些简单的逻辑.在开发Winform各种类型项 ...

  2. 【winform程序】自定义webrowser控件调用IE的版本

    修改注册表: bit: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROW ...

  3. WinForm中使用自定义Tooltip控件

    private ToolTip tooltipCtr; 构造函数中: 隐藏默认的Tooltip:this.ShowCellToolTips = false; this.tooltipCtr = new ...

  4. .NET各大平台数据列表控件绑定原理及比较(WebForm、Winform、WPF)

    说说WebForm: 数据列表控件: WebForm 下的列表绑定控件基本就是GridView.DataList.Repeater:当然还有其它DropDownList.ListBox等. 它们的共同 ...

  5. WPF自定义控件与样式(7)-列表控件DataGrid与ListView自定义样式

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要内容: Dat ...

  6. Android自定义标签列表控件LabelsView解析

    版权声明:本文为博主原创文章,未经博主允许不得转载. 无论是在移动端的App,还是在前端的网页,我们经常会看到下面这种标签的列表效果:   标签从左到右摆放,一行显示不下时自动换行.这样的效果用And ...

  7. 【转】WPF自定义控件与样式(7)-列表控件DataGrid与ListView自定义样式

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等. 本文主要内容: DataGrid自定义样式: ListView自定义样式: 二.Dat ...

  8. (转载)Android自定义标签列表控件LabelsView解析

    Android自定义标签列表控件LabelsView解析 作者 donkingliang 关注 2017.03.15 20:59* 字数 759 阅读 406评论 0喜欢 3 无论是在移动端的App, ...

  9. Winform自定义键盘控件开发及使用

    最近有学员提出项目中要使用键盘控件,系统自带的osk.exe不好用,于是就有了下面的内容: 首先是进行自定义键盘控件的开发,其实核心大家都知道,就是利用SendKeys.Send发送相应 的字符,但是 ...

随机推荐

  1. Atitit 基于图片图像 与文档混合文件夹的分类

    Atitit 基于图片图像 与文档混合文件夹的分类 太小的文档(txt doc csv exl ppt pptx)单独分类 Mov10KminiDoc 但是可能会有一些书法图片迁移,因为他们很微小,需 ...

  2. flow.ci + Github + Slack 一步步搭建 Python 自动化持续集成

    理想的程序员必须懒惰,永远追随自动化法则.Automating shapes smarter future. 在一个 Python 项目的开发过程中可能会做的事情:编译.手动或自动化测试.部署环境配置 ...

  3. Android WebView 总结 —— 使用HTML5播放视频及全屏方案

    在APP开发的过程中,会碰到需要在WebView中播放视频的需求,下面讲解一下如何在WebView中使用html5播放视频. 1.让视频在各个Android版本能够正常播放 在AndroidManif ...

  4. SSM环境搭建(接口编程方式)

    一直用ssm在开发项目,之前都是直接copy别人的项目,今天趁着项目刚刚交付,自己搭建一下ssm环境,做个记录 一.创建项目.引入jar包,因为版本不一样,就不贴出这部分的内容了.个人平时的习惯是,先 ...

  5. png图片制作任意颜色的小图标

    本内容只要是对张鑫旭PNG格式小图标的CSS任意颜色赋色技术的这篇文章进行详细说明. HTML: <i class="icon"><i class="i ...

  6. 用MVVM做了一个保存网页的工具-上篇

    前言: 你是否有过收藏了别人博客或文章,当想用的时候却找不到?你是否有过收藏了别人博客或文章,却因为没有网络而打不开网页?OK,下面是我做的一个工具,有兴趣的同学们可以download 玩下,哈哈^. ...

  7. 前端工程师技能之photoshop巧用系列第五篇——雪碧图

    × 目录 [1]定义 [2]应用场景 [3]合并[4]实现[5]维护 前面的话 前面已经介绍过,描述性图片最终要合并为雪碧图.本文是photoshop巧用系列第五篇——雪碧图 定义 css雪碧图(sp ...

  8. NYOJ995硬币找零(简单dp)

    /* 题意:给你不同面额的硬币(每种硬币无限多),需要找零的面值是T,用这些硬币进行找零, 如果T恰好能被找零,输出最少需要的硬币的数目!否则请输出剩下钱数最少的找零方案中的最少硬币数! 思路:转换成 ...

  9. poj 2385Apple Catching(简单dp)

    /* 题意: 有两棵苹果树,每一棵苹果树每一秒间隔的掉落下来一个苹果,一个人在树下接住苹果,不让苹果掉落! 人在两棵树之间的移动是很快的!但是这个人移动的次数是有限制的,问最多可以接住多少个苹果! 思 ...

  10. nodejs在Liunx上的部署生产方式-PM2

    先安装:npm install -g pm2 (注意:使用它要先安装它,用root账号和全局模式安装一下) 安装完成使用:pm2 -v 查看版本信息 安装成功之后,启动nodejs项目:pm2 sta ...