如题各位大侠,小弟新手,想豌豆荚通讯录列表的要怎么实现啊。
我用winfrom的用户控件做了个,但是效率太差了。
求帮助
我用winfrom的用户控件做了个,但是效率太差了。
求帮助
解决方案 »
- c# toolStrip中的按钮toolStripButton我设置成图片但是当鼠标移动到那的时候还是按钮形式可以按
- 请教\r,\n,\r\n在实际使用中的区别
- 怎么截串~~急~有例子
- 文本批注控件
- 哈哈!我又遇到棘手的问题了?
- 求助:在C#中如何调用Dephi写的接口函数(内含结构体及结构体指针)
- 对文件的操作,得不到所要的结果,请大家帮忙看看,在线等
- 见了鬼了,插入的部分中文是乱码~!在线等.
- 高手进!取图像指针锁入内存的问题
- C#层级结构
- C#窗体 怎样用代码得知Windows Media Player播放器所播放的内容完毕了
- ASP.NET C# 用DataList控件中加子控件LinkButton,如何写链接呢?请指教,谢谢!
416310531知道的大侠求帮助,这我QQ
第二个比较麻烦但是简单,就是在panel中动态添加你需要的项目组合。namespace WindowsFormsApplication2
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region Windows 窗体设计器生成的代码 /// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// panel1
//
this.panel1.Location = new System.Drawing.Point(12, 12);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(260, 205);
this.panel1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(197, 223);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 261);
this.Controls.Add(this.button1);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false); } #endregion private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button button1;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
panel1.AutoScroll = true;
for (int i = 0; i < 20; i++)
{
Panel pan = new Panel();
pan.Width = 126;
pan.Height = 46;
PictureBox pic = new PictureBox();
pic.BackColor = Color.Red;
pic.Width = 40;
pic.Height = 40;
pic.Location = new Point(2, 3);
pan.Controls.Add(pic);
Label lbname = new Label();
lbname.Height = 20;
lbname.Location = new Point(44, 3);
pan.Controls.Add(lbname);
lbname.Text = "name" + i.ToString();
Label lbtel = new Label();
lbtel.Height = 20;
lbtel.Text = i.ToString("00000000");
lbtel.Location = new Point(44, 25);
pan.Controls.Add(lbtel);
pan.Location = new Point(2, i * 47);
panel1.Controls.Add(pan);
}
}
}
}
显示部分用了两个lable,如果需要别的东西你自己调整一下。
截获点击事件的问题,可以在pic的tag里面添加区别字段或其他区别对象,然后写统一的pic_click事件委托就可以了。我稍微修改一下后面的代码发给你。
以下是修改后的点击代码和委托代码。 private void button1_Click(object sender, EventArgs e)
{
panel1.AutoScroll = true;
for (int i = 0; i < 20; i++)
{
Panel pan = new Panel();
pan.Width = 126;
pan.Height = 46;
PictureBox pic = new PictureBox();
pic.BackColor = Color.Red;
pic.Width = 40;
pic.Height = 40;
pic.Tag = i.ToString();
pic.Click += new EventHandler(pic_Click);
pic.Location = new Point(2, 3);
pan.Controls.Add(pic);
Label lbname = new Label();
lbname.Height = 20;
lbname.Location = new Point(44, 3);
pan.Controls.Add(lbname);
lbname.Text = "name" + i.ToString();
Label lbtel = new Label();
lbtel.Height = 20;
lbtel.Text = i.ToString("00000000");
lbtel.Location = new Point(44, 25);
pan.Controls.Add(lbtel);
pan.Location = new Point(2, i * 47);
panel1.Controls.Add(pan);
}
} void pic_Click(object sender, EventArgs e)
{
MessageBox.Show(((PictureBox)sender).Tag.ToString());
}
panel1.SuspendLayout();
panel1.AutoScroll = true;
Panel[] pans = new Panel[1000];
for (int i = 0; i < pans.Length; i++)
{
pans[i] = new Panel();
pans[i].Width = 126;
pans[i].Height = 46;
PictureBox pic = new PictureBox();
pic.BackColor = Color.Red;
pic.Width = 40;
pic.Height = 40;
pic.Location = new Point(2, 3);
pans[i].Controls.Add(pic);
Label lbname = new Label();
lbname.Height = 20;
lbname.Location = new Point(44, 3);
pans[i].Controls.Add(lbname);
lbname.Text = "name" + i.ToString();
Label lbtel = new Label();
lbtel.Height = 20;
lbtel.Text = i.ToString("00000000");
lbtel.Location = new Point(44, 25);
pans[i].Controls.Add(lbtel);
pans[i].Location = new Point(2, i * 47);
}
panel1.Controls.AddRange(pans);
panel1.ResumeLayout();
} private void Form1_Load(object sender, EventArgs e)
{
this.DoubleBuffered = true;
}
SocketUp,xomix 当我循环1000个的时候果断只显示出692个停了!
Listview可以实现么?
使用GDI+画吧
我搞不懂怎么重写蛋疼的新手!
求,winfrom完成的和360手机助手中联系人一样的列表!
在添加的时候加个if,判断controls数量多大,然后如果大于多少就自动删除tag小的多少条增加大的多少条这样做。
嗯,不错的思路,我试试呢。谢谢 xomix