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发送相应 的字符,但是 ...
随机推荐
- [常见问题]Project facet Java versin 1.8 is not support.
发生这个问题的原因是我们的java编译环境(JDK版本),与tomcat运行环境(JDK或JRE版本)不一致导致的. 到eclipse的设置中找到compile项(或右键项目进入),看一下编译环境的J ...
- javaweb学习总结—Apache的DBUtils框架学习
注明: 本文转载自http://www.cnblogs.com/xdp-gacl/p/4007225.html 一.commons-dbutils简介 commons-dbutils 是 Apache ...
- [C#基础]基础知识一: 面向对象的基本知识.
激励自己有时间多看看.!! C#基础共分为七个部分: 一: 面向对象 二: 值类型, 引用类型, 字符串操作 三: 集合文件操作 四: 正则表达式 五: XML操作 六: 委托, 事件 七: 反射 1 ...
- SpringSide 部署showcase项目出现 JAX-RS (REST Web Services) 2.0 can not be installed错误!
maven+springmvc错误 JAX-RS (REST Web Services) 2.0 can not be installed 项目problem提示错误 JAX-RS (REST Web ...
- Html与CSS快速入门02-HTML基础应用
这部分是html细节知识的学习. 快速入门系列--HTML-01简介 快速入门系列--HTML-02基础元素 快速入门系列--HTML-03高级元素和布局 快速入门系列--HTML-04进阶概念 示例 ...
- iReport 下载地址
iReport 下载地址: https://osdn.jp/projects/sfnet_ireport/releases/# 来自为知笔记(Wiz)
- .NET面试题解析(02)-拆箱与装箱
系列文章目录地址: .NET面试题解析(00)-开篇来谈谈面试 & 系列文章索引 装箱和拆箱几乎是所有面试题中必考之一,看上去简单,就往往容易被忽视.其实它一点都不简单的,一个简单的问题也 ...
- CSS学习目录
前面的话 CSS是前端工程师的基本功,但好多执迷于学习javascript的人的基本功并不扎实.可能一些人从w3school网站匆匆过了一遍,只是对CSS常用概念有一些表面上的理解,就一头扎进java ...
- 后端码农谈前端(CSS篇)第六课:盒子模型
元素框的最内部分是实际的内容,直接包围内容的是内边距.内边距呈现了元素的背景.内边距的边缘是边框.边框以外是外边距,外边距默认是透明的,因此不会遮挡其后的任何元素. 提示:背景应用于由内容和内边距.边 ...
- 邻接矩阵有向图(三)之 Java详解
前面分别介绍了邻接矩阵有向图的C和C++实现,本文通过Java实现邻接矩阵有向图. 目录 1. 邻接矩阵有向图的介绍 2. 邻接矩阵有向图的代码说明 3. 邻接矩阵有向图的完整源码 转载请注明出处:h ...