|
Тема |
Re: Я ме светнете на C# как става... (скролери) [re: Любитeл] |
|
Автор |
BlackEarl (гледам умно) |
|
Публикувано | 15.09.04 09:50 |
|
|
Единственото за което се сещам е да наследиш контролата и да прихванеш събитието. Пробвай това:
//CustomList.cs ->nasledenata kontrola w slu4aq polzwan listbox
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace scroll
{
/// <summary>
/// Summary description for CurtomList.
/// </summary>
public class CurtomList : System.Windows.Forms.ListBox
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public const int WM_VSCROLL = 0x0115;
public CurtomList()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitComponent call
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
protected override void WndProc(ref Message m)
{
if(m.Msg==WM_VSCROLL)
{
for(int i=0;i<Parent.Controls.Count;i++)
if(Parent.Controls.Name=="listBox1")
{
scroll.CurtomList l=(scroll.CurtomList)Parent.Controls;
l.TopIndex=this.TopIndex;
break;
}
}
base.WndProc (ref m);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
protected override void OnPaint(PaintEventArgs pe)
{
// TODO: Add custom paint code here
// Calling the base class OnPaint
base.OnPaint(pe);
}
}
}
всъщност от това същественото е само константата WM_VSCROLL и WndProc
ще трябва да смениш името на listBox1 с това на твоята контрола
самото ползване става по следния начин:
namespace scroll
{
public class Form1 : System.Windows.Forms.Form
{
private scroll.CurtomList listBox1;
private scroll.CurtomList listBox2;
....
Надявам се това да помогне
|
| |
|
|
|