By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,699 Members | 1,453 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,699 IT Pros & Developers. It's quick & easy.

Grid Scroll Bar

P: n/a
Hi

Is there a way to force a vertical scroll bar on the data grid, even if the
data grid has no rows?

Thanks

Regards
Nov 20 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
in vb.nei created a timer control in design time, and its
default properties were interval = 3000, enabled = false

when u click on a button it enables the timer and that
works fine, but on another form when they press
the "okay" button it should set the interval to the ,
user specification, but it remains the same as the
default one set in desing time, it changes if its on the
same form perfectly, but not if that command is called
from another form. (in a midule i made the form
declaration as so "public cmain as new main"
then to change the interval it was this
cmain.timer.interval = txt.text

thx
Nov 20 '05 #2

P: n/a
No.

OHM
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi

Is there a way to force a vertical scroll bar on the data grid, even if the data grid has no rows?

Thanks

Regards

Nov 20 '05 #3

P: n/a
Hello,

"Andrew" <ve**********@hotmail.com> schrieb:
in vb.nei created a timer control in design time, and its
default properties were interval = 3000, enabled = false

when u click on a button it enables the timer and that
works fine, but on another form when they press
the "okay" button it should set the interval to the ,
user specification, but it remains the same as the
default one set in desing time, it changes if its on the
same form perfectly, but not if that command is called
from another form. (in a midule i made the form
declaration as so "public cmain as new main"
then to change the interval it was this
cmain.timer.interval = txt.text


I think the problem is that you create a _new_ instance of the form in the
module and change the 'Interval' property of its timer control. You can add
a parameter to your procedure and pass the reference to your instance of the
form:

\\\
Public Module Moo
Public Sub Foo(ByVal Goo As Form1)
Goo.Timer1.Interval = 100
End Sub
End Module
///

In the form:

\\\
Moo.Foo(Me)
///

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #4

P: n/a
Yes, but as far as I know you need to do it all yourself. So if you plan on
reusing this sometime you can always just derive from the DataGrid and wire
in the logic yourself. You may need to make a few modifications to the code
below, but this should get you started.

public class MyDataGrid : System.Windows.Forms.DataGrid
{
public MyDataGrid ()
{
this.VertScrollBar.Visible = true;
this.VertScrollBar.VisibleChanged += new
EventHandler(VertScrollBar_VisibleChanged);
}

private void VertScrollBar_VisibleChanged(object sender, EventArgs e)
{
this.VertScrollBar.Visible = true;
}

protected override void OnResize(System.EventArgs e)
{
// TODO: Need to take caption height and some other aspects into
consideration.
this.VertScrollBar.Bounds = new Rectangle(this.ClientRectangle.Width -
this.VertScrollBar.Width, 0, this.VertScrollBar.Width,
this.ClientRectangle.Height);
base.OnResize(e);
}
}

--
Tim Wilson
Windows Embedded MVP
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi

Is there a way to force a vertical scroll bar on the data grid, even if the data grid has no rows?

Thanks

Regards

Nov 20 '05 #5

P: n/a
I stand corrected then. Was this tested on Cx or VB.NET ?

Regards - OHM

"Tim Wilson [MVP]" <Ti********@Rogers.com> wrote in message
news:ef**************@TK2MSFTNGP09.phx.gbl...
Yes, but as far as I know you need to do it all yourself. So if you plan on reusing this sometime you can always just derive from the DataGrid and wire in the logic yourself. You may need to make a few modifications to the code below, but this should get you started.

public class MyDataGrid : System.Windows.Forms.DataGrid
{
public MyDataGrid ()
{
this.VertScrollBar.Visible = true;
this.VertScrollBar.VisibleChanged += new
EventHandler(VertScrollBar_VisibleChanged);
}

private void VertScrollBar_VisibleChanged(object sender, EventArgs e)
{
this.VertScrollBar.Visible = true;
}

protected override void OnResize(System.EventArgs e)
{
// TODO: Need to take caption height and some other aspects into
consideration.
this.VertScrollBar.Bounds = new Rectangle(this.ClientRectangle.Width -
this.VertScrollBar.Width, 0, this.VertScrollBar.Width,
this.ClientRectangle.Height);
base.OnResize(e);
}
}

--
Tim Wilson
Windows Embedded MVP
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi

Is there a way to force a vertical scroll bar on the data grid, even if

the
data grid has no rows?

Thanks

Regards


Nov 20 '05 #6

P: n/a
This is C#, but shouldn't matter. I fully expect that this would run in a
VB.Net application (if translated, of course). And this could also be
written as a control in C# and then used in a VB.Net app - it's the beauty
of IL code.

--
Tim Wilson
Windows Embedded MVP

"One Handed Man [ OHM ]" <te***************************@BTOpenworld.com>
wrote in message news:OO****************@TK2MSFTNGP12.phx.gbl...
I stand corrected then. Was this tested on Cx or VB.NET ?

Regards - OHM

"Tim Wilson [MVP]" <Ti********@Rogers.com> wrote in message
news:ef**************@TK2MSFTNGP09.phx.gbl...
Yes, but as far as I know you need to do it all yourself. So if you plan

on
reusing this sometime you can always just derive from the DataGrid and

wire
in the logic yourself. You may need to make a few modifications to the

code
below, but this should get you started.

public class MyDataGrid : System.Windows.Forms.DataGrid
{
public MyDataGrid ()
{
this.VertScrollBar.Visible = true;
this.VertScrollBar.VisibleChanged += new
EventHandler(VertScrollBar_VisibleChanged);
}

private void VertScrollBar_VisibleChanged(object sender, EventArgs e)
{
this.VertScrollBar.Visible = true;
}

protected override void OnResize(System.EventArgs e)
{
// TODO: Need to take caption height and some other aspects into
consideration.
this.VertScrollBar.Bounds = new Rectangle(this.ClientRectangle.Width - this.VertScrollBar.Width, 0, this.VertScrollBar.Width,
this.ClientRectangle.Height);
base.OnResize(e);
}
}

--
Tim Wilson
Windows Embedded MVP
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi

Is there a way to force a vertical scroll bar on the data grid, even
if the
data grid has no rows?

Thanks

Regards



Nov 20 '05 #7

P: n/a
This is a vb group and I am getting c# examples. :( as if vb.net wasn't
difficult enough.

Regards
"Tim Wilson [MVP]" <Ti********@Rogers.com> wrote in message
news:ef**************@TK2MSFTNGP09.phx.gbl...
Yes, but as far as I know you need to do it all yourself. So if you plan on reusing this sometime you can always just derive from the DataGrid and wire in the logic yourself. You may need to make a few modifications to the code below, but this should get you started.

public class MyDataGrid : System.Windows.Forms.DataGrid
{
public MyDataGrid ()
{
this.VertScrollBar.Visible = true;
this.VertScrollBar.VisibleChanged += new
EventHandler(VertScrollBar_VisibleChanged);
}

private void VertScrollBar_VisibleChanged(object sender, EventArgs e)
{
this.VertScrollBar.Visible = true;
}

protected override void OnResize(System.EventArgs e)
{
// TODO: Need to take caption height and some other aspects into
consideration.
this.VertScrollBar.Bounds = new Rectangle(this.ClientRectangle.Width -
this.VertScrollBar.Width, 0, this.VertScrollBar.Width,
this.ClientRectangle.Height);
base.OnResize(e);
}
}

--
Tim Wilson
Windows Embedded MVP
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi

Is there a way to force a vertical scroll bar on the data grid, even if

the
data grid has no rows?

Thanks

Regards


Nov 20 '05 #8

P: n/a
Yes this example is in C#. But you posted your question to a whole bunch of
newsgroups and I am responding from the
microsoft.public.dotnet.framework.windowsforms.con trols newsgroup. So there
is no language specification here. There are many C# to VB.Net converters
out there. Here is one:
http://www.aspalliance.com/aldotnet/...translate.aspx

--
Tim Wilson
Windows Embedded MVP

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
This is a vb group and I am getting c# examples. :( as if vb.net wasn't
difficult enough.

Regards
"Tim Wilson [MVP]" <Ti********@Rogers.com> wrote in message
news:ef**************@TK2MSFTNGP09.phx.gbl...
Yes, but as far as I know you need to do it all yourself. So if you plan

on
reusing this sometime you can always just derive from the DataGrid and

wire
in the logic yourself. You may need to make a few modifications to the

code
below, but this should get you started.

public class MyDataGrid : System.Windows.Forms.DataGrid
{
public MyDataGrid ()
{
this.VertScrollBar.Visible = true;
this.VertScrollBar.VisibleChanged += new
EventHandler(VertScrollBar_VisibleChanged);
}

private void VertScrollBar_VisibleChanged(object sender, EventArgs e)
{
this.VertScrollBar.Visible = true;
}

protected override void OnResize(System.EventArgs e)
{
// TODO: Need to take caption height and some other aspects into
consideration.
this.VertScrollBar.Bounds = new Rectangle(this.ClientRectangle.Width - this.VertScrollBar.Width, 0, this.VertScrollBar.Width,
this.ClientRectangle.Height);
base.OnResize(e);
}
}

--
Tim Wilson
Windows Embedded MVP
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi

Is there a way to force a vertical scroll bar on the data grid, even
if the
data grid has no rows?

Thanks

Regards



Nov 20 '05 #9

P: n/a
Impressive. I used the converter and tried out your code. It works very
well.

"Tim Wilson [MVP]" <Ti********@Rogers.com> wrote in message
news:ON**************@TK2MSFTNGP11.phx.gbl...
Yes this example is in C#. But you posted your question to a whole bunch of newsgroups and I am responding from the
microsoft.public.dotnet.framework.windowsforms.con trols newsgroup. So there is no language specification here. There are many C# to VB.Net converters
out there. Here is one:
http://www.aspalliance.com/aldotnet/...translate.aspx

--
Tim Wilson
Windows Embedded MVP

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
This is a vb group and I am getting c# examples. :( as if vb.net wasn't
difficult enough.

Regards
"Tim Wilson [MVP]" <Ti********@Rogers.com> wrote in message
news:ef**************@TK2MSFTNGP09.phx.gbl...
Yes, but as far as I know you need to do it all yourself. So if you plan
on
reusing this sometime you can always just derive from the DataGrid and

wire
in the logic yourself. You may need to make a few modifications to the

code
below, but this should get you started.

public class MyDataGrid : System.Windows.Forms.DataGrid
{
public MyDataGrid ()
{
this.VertScrollBar.Visible = true;
this.VertScrollBar.VisibleChanged += new
EventHandler(VertScrollBar_VisibleChanged);
}

private void VertScrollBar_VisibleChanged(object sender, EventArgs
e) {
this.VertScrollBar.Visible = true;
}

protected override void OnResize(System.EventArgs e)
{
// TODO: Need to take caption height and some other aspects into
consideration.
this.VertScrollBar.Bounds = new

Rectangle(this.ClientRectangle.Width - this.VertScrollBar.Width, 0, this.VertScrollBar.Width,
this.ClientRectangle.Height);
base.OnResize(e);
}
}

--
Tim Wilson
Windows Embedded MVP
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> Hi
>
> Is there a way to force a vertical scroll bar on the data grid, even if the
> data grid has no rows?
>
> Thanks
>
> Regards
>
>



Nov 20 '05 #10

P: n/a
Why not post the vb code here?

Thanks

Regards

"One Handed Man [ OHM ]" <te***************************@BTOpenworld.com>
wrote in message news:uB**************@TK2MSFTNGP09.phx.gbl...
Impressive. I used the converter and tried out your code. It works very
well.

"Tim Wilson [MVP]" <Ti********@Rogers.com> wrote in message
news:ON**************@TK2MSFTNGP11.phx.gbl...
Yes this example is in C#. But you posted your question to a whole bunch

of
newsgroups and I am responding from the
microsoft.public.dotnet.framework.windowsforms.con trols newsgroup. So

there
is no language specification here. There are many C# to VB.Net converters
out there. Here is one:
http://www.aspalliance.com/aldotnet/...translate.aspx

--
Tim Wilson
Windows Embedded MVP

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
This is a vb group and I am getting c# examples. :( as if vb.net wasn't difficult enough.

Regards
"Tim Wilson [MVP]" <Ti********@Rogers.com> wrote in message
news:ef**************@TK2MSFTNGP09.phx.gbl...
> Yes, but as far as I know you need to do it all yourself. So if you plan on
> reusing this sometime you can always just derive from the DataGrid and wire
> in the logic yourself. You may need to make a few modifications to the code
> below, but this should get you started.
>
> public class MyDataGrid : System.Windows.Forms.DataGrid
> {
> public MyDataGrid ()
> {
> this.VertScrollBar.Visible = true;
> this.VertScrollBar.VisibleChanged += new
> EventHandler(VertScrollBar_VisibleChanged);
> }
>
> private void VertScrollBar_VisibleChanged(object sender, EventArgs e) > {
> this.VertScrollBar.Visible = true;
> }
>
> protected override void OnResize(System.EventArgs e)
> {
> // TODO: Need to take caption height and some other aspects into
> consideration.
> this.VertScrollBar.Bounds = new

Rectangle(this.ClientRectangle.Width -
> this.VertScrollBar.Width, 0, this.VertScrollBar.Width,
> this.ClientRectangle.Height);
> base.OnResize(e);
> }
> }
>
> --
> Tim Wilson
> Windows Embedded MVP
> "John" <jo**@nospam.infovis.co.uk> wrote in message
> news:%2****************@TK2MSFTNGP12.phx.gbl...
> > Hi
> >
> > Is there a way to force a vertical scroll bar on the data grid,

even if
> the
> > data grid has no rows?
> >
> > Thanks
> >
> > Regards
> >
> >
>
>



Nov 20 '05 #11

P: n/a
Instantiate this at Form class level and remember to add it to the
form.controls collection

me.controls.add( InstantiatedGrid )
Public Class MyDataGrid
Inherits System.Windows.Forms.DataGrid

Public Sub New()
Me.VertScrollBar.Visible = True
AddHandler Me.VertScrollBar.VisibleChanged, AddressOf
VertScrollBar_VisibleChanged
End Sub 'New
Private Sub VertScrollBar_VisibleChanged(sender As Object, e As
EventArgs)
Me.VertScrollBar.Visible = True
End Sub 'VertScrollBar_VisibleChanged
Protected Overrides Sub OnResize(e As System.EventArgs)
' TODO: Need to take caption height and some other aspects into
consideration.__unknown
Me.VertScrollBar.Bounds = New Rectangle(Me.ClientRectangle.Width -
Me.VertScrollBar.Width, 0, Me.VertScrollBar.Width,
Me.ClientRectangle.Height) '
'ToDo: Error processing original source shown below
'
'
'-----^--- Syntax error: 'identifier' expected
MyBase.OnResize(e)
End Sub 'OnResize
End Class 'MyDataGrid
"
Nov 20 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.