Click here to Skip to main content
15,892,059 members
Home / Discussions / Windows Forms
   

Windows Forms

 
QuestionHow to kill exe? Pin
NanaAM18-May-07 22:28
NanaAM18-May-07 22:28 
AnswerRe: How to kill exe? Pin
Giorgi Dalakishvili18-May-07 23:11
mentorGiorgi Dalakishvili18-May-07 23:11 
QuestionHow to Insert row from Binded Combo Box Pin
P.T.R.K18-May-07 20:31
P.T.R.K18-May-07 20:31 
AnswerRe: How to Insert row from Binded Combo Box Pin
PandemoniumPasha19-May-07 19:16
PandemoniumPasha19-May-07 19:16 
AnswerRe: How to Insert row from Binded Combo Box Pin
Ch_Shahzad iqbal21-May-07 23:19
Ch_Shahzad iqbal21-May-07 23:19 
QuestionHow to scroll two listbox together in c# ? Pin
nav_smec18-May-07 1:07
nav_smec18-May-07 1:07 
QuestionRe: How to scroll two listbox together in c# ? Pin
ScottM123-May-07 2:26
ScottM123-May-07 2:26 
AnswerRe: How to scroll two listbox together in c# ? Pin
nav_smec2-Jun-07 0:13
nav_smec2-Jun-07 0:13 
Hello smyer,

First you made your own scrolling listbox using this code :

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace myscrollList
{
class scrollList : System.Windows.Forms.ListBox
{
[Category("Action")]
//public event ScrollEventHandler Scroll = null;



private const int WM_HSCROLL = 0x114;
private const int WM_VSCROLL = 0x115;

public event ScrollEventHandler OnHorizontalScroll;
public event ScrollEventHandler OnVerticalScroll;


private const int SB_LINEUP = 0;
private const int SB_LINELEFT = 0;
private const int SB_LINEDOWN = 1;
private const int SB_LINERIGHT = 1;
private const int SB_PAGEUP = 2;
private const int SB_PAGELEFT = 2;
private const int SB_PAGEDOWN = 3;
private const int SB_PAGERIGHT = 3;
private const int SB_THUMBPOSITION = 4;
private const int SB_THUMBTRACK = 5;
private const int SB_PAGETOP = 6;
private const int SB_LEFT = 6;
private const int SB_PAGEBOTTOM = 7;
private const int SB_RIGHT = 7;
private const int SB_ENDSCROLL = 8;

private const int SIF_TRACKPOS = 0x10;
private const int SIF_RANGE = 0x1;
private const int SIF_POS = 0x4;
private const int SIF_PAGE = 0x2;
private const int SIF_ALL = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;

[DllImport("user32.dll", SetLastError = true)]
private static extern int GetScrollInfo(
IntPtr hWnd, int n, ref ScrollInfoStruct lpScrollInfo);


private struct ScrollInfoStruct
{
public int cbSize;
public int fMask;
public int nMin;
public int nMax;
public int nPage;
public int nPos;
public int nTrackPos;
}

protected override void WndProc(ref System.Windows.Forms.Message msg)
{
if (msg.Msg == WM_HSCROLL)
{
if (OnHorizontalScroll != null)
{
ScrollInfoStruct si = new ScrollInfoStruct();
si.fMask = SIF_ALL;
si.cbSize = Marshal.SizeOf(si);
GetScrollInfo(msg.HWnd, 0, ref si);

if (msg.WParam.ToInt32() == SB_ENDSCROLL)
{
ScrollEventArgs sargs = new ScrollEventArgs(
ScrollEventType.EndScroll,
si.nPos);
OnHorizontalScroll(this, sargs);
}
}
}
if (msg.Msg == WM_VSCROLL)
{
if (OnVerticalScroll != null)
{
ScrollInfoStruct si = new ScrollInfoStruct();
si.fMask = SIF_ALL;
si.cbSize = Marshal.SizeOf(si);
GetScrollInfo(msg.HWnd, 0, ref si);

if (msg.WParam.ToInt32() == SB_ENDSCROLL)
{
ScrollEventArgs sargs = new ScrollEventArgs(
ScrollEventType.EndScroll,
si.nPos);
OnVerticalScroll(this, sargs);
}
}
}
base.WndProc(ref msg);
}


private void InitializeComponent()
{
this.SuspendLayout();
//
// scrolled
//
this.Size = new System.Drawing.Size(120, 95);
this.ResumeLayout(false);
}
}
}

After this .........
Drag your listbox on windows forms and than sync two listbox together using this.......

private void scrollList1_OnVerticalScroll(object sender, ScrollEventArgs e)
{
scrollList2.TopIndex = scrollList1.TopIndex;
}


private void scrollList2_OnVerticalScroll(object sender, ScrollEventArgs e)
{
scrollList1.TopIndex = scrollList2.TopIndex;
}

I hope this will work..........Cool | :cool:

nav_smec
GeneralRe: How to scroll two listbox together in c# ? Pin
ScottM13-Jun-07 20:11
ScottM13-Jun-07 20:11 
QuestionCheckedListBox.CheckedItems Issue Pin
jimmahnow17-May-07 1:38
jimmahnow17-May-07 1:38 
AnswerRe: CheckedListBox.CheckedItems Issue Pin
Rob_ICS17-May-07 2:59
Rob_ICS17-May-07 2:59 
AnswerRe: CheckedListBox.CheckedItems Issue Pin
Ch_Shahzad iqbal18-May-07 0:41
Ch_Shahzad iqbal18-May-07 0:41 
GeneralRe: CheckedListBox.CheckedItems Issue Pin
nav_smec18-May-07 18:01
nav_smec18-May-07 18:01 
QuestionProblem occour when registering dll on win xp Pin
koolprasad200317-May-07 1:31
professionalkoolprasad200317-May-07 1:31 
AnswerRe: Problem occour when registering dll on win xp Pin
Christian Graus17-May-07 2:29
protectorChristian Graus17-May-07 2:29 
AnswerRe: Problem occour when registering dll on win xp Pin
Pete O'Hanlon22-May-07 10:12
mvePete O'Hanlon22-May-07 10:12 
QuestionTicker scrolling Pin
nilima Dash17-May-07 1:13
nilima Dash17-May-07 1:13 
AnswerRe: Ticker scrolling Pin
Christian Graus17-May-07 2:33
protectorChristian Graus17-May-07 2:33 
Questionscrolling two controls with one scroll bar Pin
mamirbalouch16-May-07 22:54
mamirbalouch16-May-07 22:54 
QuestionInsert Stored Procedure taking values from vb Help Pin
Vimalsoft(Pty) Ltd16-May-07 3:38
professionalVimalsoft(Pty) Ltd16-May-07 3:38 
QuestionHow to place Control at column header Pin
Rahul8315-May-07 19:47
Rahul8315-May-07 19:47 
QuestionCombo box class Pin
paulsmithx15-May-07 19:46
paulsmithx15-May-07 19:46 
AnswerRe: Combo box class Pin
Ch_Shahzad iqbal15-May-07 23:34
Ch_Shahzad iqbal15-May-07 23:34 
GeneralRe: Combo box class Pin
paulsmithx16-May-07 1:10
paulsmithx16-May-07 1:10 
Questionicons for navigation and buttons Pin
Hasan Jaffal15-May-07 13:16
Hasan Jaffal15-May-07 13:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.