C#Winform VScrollBar+Pannel自定义列表控件(原)
本人开发的开发者技术变现资源聚集地,大家支持下,下面是网址
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自定义列表控件(原)的更多相关文章
- 在Winform界面使用自定义用户控件及TabelPanel和StackPanel布局控件
在很多时候,我们做一些非常规化的界面的时候,往往需要创建一些用户控件,在其中绘制好一些基础的界面块,作为后续重复使用的一个单元,用户控件同时也可以封装处理一些简单的逻辑.在开发Winform各种类型项 ...
- 【winform程序】自定义webrowser控件调用IE的版本
修改注册表: bit: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROW ...
- WinForm中使用自定义Tooltip控件
private ToolTip tooltipCtr; 构造函数中: 隐藏默认的Tooltip:this.ShowCellToolTips = false; this.tooltipCtr = new ...
- .NET各大平台数据列表控件绑定原理及比较(WebForm、Winform、WPF)
说说WebForm: 数据列表控件: WebForm 下的列表绑定控件基本就是GridView.DataList.Repeater:当然还有其它DropDownList.ListBox等. 它们的共同 ...
- WPF自定义控件与样式(7)-列表控件DataGrid与ListView自定义样式
一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要内容: Dat ...
- Android自定义标签列表控件LabelsView解析
版权声明:本文为博主原创文章,未经博主允许不得转载. 无论是在移动端的App,还是在前端的网页,我们经常会看到下面这种标签的列表效果: 标签从左到右摆放,一行显示不下时自动换行.这样的效果用And ...
- 【转】WPF自定义控件与样式(7)-列表控件DataGrid与ListView自定义样式
一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等. 本文主要内容: DataGrid自定义样式: ListView自定义样式: 二.Dat ...
- (转载)Android自定义标签列表控件LabelsView解析
Android自定义标签列表控件LabelsView解析 作者 donkingliang 关注 2017.03.15 20:59* 字数 759 阅读 406评论 0喜欢 3 无论是在移动端的App, ...
- Winform自定义键盘控件开发及使用
最近有学员提出项目中要使用键盘控件,系统自带的osk.exe不好用,于是就有了下面的内容: 首先是进行自定义键盘控件的开发,其实核心大家都知道,就是利用SendKeys.Send发送相应 的字符,但是 ...
随机推荐
- CentOS6.5下安装JDK
之前一直没有完全的总结出一篇关于Linux下安装Java的过程,今天正好就整理下. 下载jdk 如果在官网下载比较慢,那么可以到我的云盘分享上,下载jdk 1.8.0的版本: 下载地址参考链接 解压缩 ...
- 创建Cookie,简单模拟登录,记录登录名,购物车记录先前添加内容,session控制登录
工作任务:模拟淘宝登录和购物车功能:使用cookie记录登录名,下次登录时能够记得上次的登录名,使用cookie模拟购物车功能,使用session记住登录信息并验证是否登录,防止利用url打开网站, ...
- jQuery学习-打字游戏
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8&quo ...
- Linux常用命令03
上篇我们写到,如何编辑文件,我们有时候,在编辑的时候,有可能会异常的退出,这样的话, linux会针对这个文件生成一个swp文件,当你下次进入vi模式时,就会提示你一个错误 这样,即使你按enter键 ...
- javascript中可变值与不可变值(原始值)
字符串原始值修改不了1 var str = "abc"; 2 str[0] = "d"; 3 console.log(str[1]="f") ...
- SQL PASS将于8月24日在北京中医药大学举办线下活动
活动主题:复制架构的实现和调优以及SQL Server BI在传统行业的应用 地点:北三环东路11号 北京中医药大学 白色的1号楼教学楼后楼5层511房间 时间:2013年8月24日 9:00-12: ...
- Js内存回收
Javascript的世界中,隐藏了很多内存陷阱,不能得到合理释放的内存会埋下各种隐患,本文旨在以实用角度去解读Js涉及到的内存,且看勇士如何斗恶龙~ javascript 内存 回收 本文可以看做是 ...
- valueOf()方法
前面的话 关于类型转换,对象常见的两个方法是toString()和valueOf().实际上,这两个方法也可以应用在包装类型上.前面已经介绍过toString()方法,本文将介绍valueOf()方法 ...
- 深入理解CSS计数器
× 目录 [1]创建计数器 [2]使用计数器 [3]DEMO 前面的话 我们对计数器已经不陌生了,有序列表中的列表项标志就是计数器. 创建计数器 创建计数器的基础包括两个方面,一是能重置计数器的起点, ...
- Android登录等待效果
上一篇为大家分享了关于AsyncTask的使用,本篇结合AsyncTask为大家介绍一个我们经常看到的一个效果,就是当我们点击登录后,会弹出一个请等待的小窗体,这个效果是如何实现的呢?本篇我就带大家简 ...