This is a multi-part message in MIME format.

------=_NextPart_000_0008_01C356B4.FB15D580
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

How do I find out the size (specifically width) of a listbox's =
(specifically datagrid) "viewport" where the "viewport" does not contain =
borders (Fixed3D and otherwise), scrollbars, etc. ?

Microsoft defines a "viewport" in help text for the =
"DataGrid.VisibleColumnCount" property as so: "The viewport is the =
rectangular area through which the grid is visible." Well that's =
exactly what I need but where do I get it and it's attributes?

I'm asking because I'm writing a method which fills the width of a =
DataGrid with the columns defined in the active TableStyle. The problem =
is that I can't get the width of the datagrid which does not include the =
border, scrollbars, etc. =20

I've tried the following and they all refer to the width of the =
ClientRectangle which inclues scrollbars, borders, etc.

dataGrid.Width=20
dataGrid.ClientRectangle.Width=20
dataGrid.Bounds.Width=20
dataGrid.DisplayRectangle.Width
dataGrid.Size.Width

If I allocate column widths such that the total of all column widths is =
equal to, say, dataGrid.Width, I still get a horizontal scrollbar. The =
difference between dataGrid.Width and this total of all column widths is =
the width of say a 3D border, vertical scrollbar, etc.

Any suggestions?

Kristin

Kristin Barker=20
Principal Software Engineer=20
Email: kristin_barker@natureserve.org=20
http://www.natureserve.org
------=_NextPart_000_0008_01C356B4.FB15D580
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D""><FONT face=3DArial size=3D2>How =
do I find out=20
the size (specifically width) of a listbox's (specifically datagrid) =
"viewport"=20
where the "viewport" does not contain borders (Fixed3D and otherwise),=20
scrollbars, etc. ?<BR><BR>Microsoft defines a "viewport" in help text =
for the=20
"DataGrid.VisibleColumnCount" property as so: "The viewport is the =
rectangular=20
area through which the grid is visible."&nbsp; Well that's exactly what =
I need=20
but where do I get it and it's attributes?<BR><BR>I'm asking because I'm =
writing=20
a method which fills the width of a DataGrid with the columns defined in =
the=20
active TableStyle.&nbsp; The problem is that I can't get the width of =
the=20
datagrid which does not include the border, scrollbars, etc.&nbsp; =
<BR><BR>I've=20
tried the following and they all refer to the width of the =
ClientRectangle which=20
inclues scrollbars, borders, etc.<BR><BR>dataGrid.Width=20
<BR>dataGrid.ClientRectangle.Width <BR>dataGrid.Bounds.Width=20
<BR>dataGrid.DisplayRectangle.Width<BR>dataGrid.Size.Width<BR><BR>If I =
allocate=20
column widths such that the total of all column widths is equal to, say, =

dataGrid.Width, I still get a horizontal scrollbar.&nbsp; The difference =
between=20
dataGrid.Width and this total of all column widths is the width of say a =
3D=20
border, vertical scrollbar, etc.<BR><BR>Any=20
suggestions?<BR><BR>Kristin<BR><BR>Kristin Barker <BR>Principal Software =

Engineer <BR>Email: kristin_barker@natureserve.org=20
<BR>http://www.natureserve.org </FONT></BODY></HTML>

------=_NextPart_000_0008_01C356B4.FB15D580--

Re: DataGrid (or ListBox) "Viewport" Size by Craig

Craig
Wed Jul 30 20:31:23 CDT 2003

This is a multi-part message in MIME format.

------=_NextPart_000_00C5_01C356D9.8AB89370
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Have you checked out the Control.ClientRectangle property?

--=20
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET


"Kristin" <kristin_barker@natureserve.org> wrote in message =
news:%23kSeBatVDHA.1316@TK2MSFTNGP12.phx.gbl...
How do I find out the size (specifically width) of a listbox's =
(specifically datagrid) "viewport" where the "viewport" does not contain =
borders (Fixed3D and otherwise), scrollbars, etc. ?

Microsoft defines a "viewport" in help text for the =
"DataGrid.VisibleColumnCount" property as so: "The viewport is the =
rectangular area through which the grid is visible." Well that's =
exactly what I need but where do I get it and it's attributes?

I'm asking because I'm writing a method which fills the width of a =
DataGrid with the columns defined in the active TableStyle. The problem =
is that I can't get the width of the datagrid which does not include the =
border, scrollbars, etc. =20

I've tried the following and they all refer to the width of the =
ClientRectangle which inclues scrollbars, borders, etc.

dataGrid.Width=20
dataGrid.ClientRectangle.Width=20
dataGrid.Bounds.Width=20
dataGrid.DisplayRectangle.Width
dataGrid.Size.Width

If I allocate column widths such that the total of all column widths =
is equal to, say, dataGrid.Width, I still get a horizontal scrollbar. =
The difference between dataGrid.Width and this total of all column =
widths is the width of say a 3D border, vertical scrollbar, etc.

Any suggestions?

Kristin

Kristin Barker=20
Principal Software Engineer=20
Email: kristin_barker@natureserve.org=20
http://www.natureserve.org
------=_NextPart_000_00C5_01C356D9.8AB89370
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>Have you checked out the =
Control.ClientRectangle=20
property?</FONT></DIV>
<DIV><BR>-- <BR>Craig Deelsnyder<BR>Microsoft MVP - ASP/ASP.NET</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Kristin" &lt;<A=20
=
href=3D"mailto:kristin_barker@natureserve.org">kristin_barker@natureserve=
.org</A>&gt;=20
wrote in message <A=20
=
href=3D"news:%23kSeBatVDHA.1316@TK2MSFTNGP12.phx.gbl">news:%23kSeBatVDHA.=
1316@TK2MSFTNGP12.phx.gbl</A>...</DIV><FONT=20
face=3DArial size=3D2>How do I find out the size (specifically width) =
of a=20
listbox's (specifically datagrid) "viewport" where the "viewport" does =
not=20
contain borders (Fixed3D and otherwise), scrollbars, etc. =
?<BR><BR>Microsoft=20
defines a "viewport" in help text for the =
"DataGrid.VisibleColumnCount"=20
property as so: "The viewport is the rectangular area through which =
the grid=20
is visible."&nbsp; Well that's exactly what I need but where do I get =
it and=20
it's attributes?<BR><BR>I'm asking because I'm writing a method which =
fills=20
the width of a DataGrid with the columns defined in the active=20
TableStyle.&nbsp; The problem is that I can't get the width of the =
datagrid=20
which does not include the border, scrollbars, etc.&nbsp; <BR><BR>I've =
tried=20
the following and they all refer to the width of the ClientRectangle =
which=20
inclues scrollbars, borders, etc.<BR><BR>dataGrid.Width=20
<BR>dataGrid.ClientRectangle.Width <BR>dataGrid.Bounds.Width=20
<BR>dataGrid.DisplayRectangle.Width<BR>dataGrid.Size.Width<BR><BR>If I =

allocate column widths such that the total of all column widths is =
equal to,=20
say, dataGrid.Width, I still get a horizontal scrollbar.&nbsp; The =
difference=20
between dataGrid.Width and this total of all column widths is the =
width of say=20
a 3D border, vertical scrollbar, etc.<BR><BR>Any=20
suggestions?<BR><BR>Kristin<BR><BR>Kristin Barker <BR>Principal =
Software=20
Engineer <BR>Email: kristin_barker@natureserve.org=20
<BR>http://www.natureserve.org </FONT></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_00C5_01C356D9.8AB89370--


Re: DataGrid (or ListBox) "Viewport" Size by Kristin

Kristin
Thu Jul 31 08:52:17 CDT 2003

This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C35749.6FD75D00
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Yes. Control.ClientRectangle is inherited by DataGrid as the =
DataGrid.ClientRectangle and includes borders, scrollbars, etc.

BTW, I reread my original posting and should clarify that the sum of all =
column widths does in fact equal the DataGrid.Width (and all of the =
other names by which this attribute goes). The problem is that this =
width includes the items outside the "viewport" and thus my columns are =
too wide, resulting in the horizontal scroll bar on the DataGrid.

Thanks for any help.

Kristin
"Craig Deelsnyder" <cdeelsny@NOSPAMyahoo.com> wrote in message =
news:e3oMzNwVDHA.1748@TK2MSFTNGP12.phx.gbl...
Have you checked out the Control.ClientRectangle property?

--=20
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET


"Kristin" <kristin_barker@natureserve.org> wrote in message =
news:%23kSeBatVDHA.1316@TK2MSFTNGP12.phx.gbl...
How do I find out the size (specifically width) of a listbox's =
(specifically datagrid) "viewport" where the "viewport" does not contain =
borders (Fixed3D and otherwise), scrollbars, etc. ?

Microsoft defines a "viewport" in help text for the =
"DataGrid.VisibleColumnCount" property as so: "The viewport is the =
rectangular area through which the grid is visible." Well that's =
exactly what I need but where do I get it and it's attributes?

I'm asking because I'm writing a method which fills the width of a =
DataGrid with the columns defined in the active TableStyle. The problem =
is that I can't get the width of the datagrid which does not include the =
border, scrollbars, etc. =20

I've tried the following and they all refer to the width of the =
ClientRectangle which inclues scrollbars, borders, etc.

dataGrid.Width=20
dataGrid.ClientRectangle.Width=20
dataGrid.Bounds.Width=20
dataGrid.DisplayRectangle.Width
dataGrid.Size.Width

If I allocate column widths such that the total of all column widths =
is equal to, say, dataGrid.Width, I still get a horizontal scrollbar. =
The difference between dataGrid.Width and this total of all column =
widths is the width of say a 3D border, vertical scrollbar, etc.

Any suggestions?

Kristin

Kristin Barker=20
Principal Software Engineer=20
Email: kristin_barker@natureserve.org=20
http://www.natureserve.org
------=_NextPart_000_000B_01C35749.6FD75D00
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>Yes. Control.ClientRectangle is =
inherited by=20
DataGrid as the DataGrid.ClientRectangle and includes borders, =
scrollbars,=20
etc.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>BTW, I reread my original posting and =
should=20
clarify that the sum of all column widths does in fact equal the =
DataGrid.Width=20
(and all of the other names by which this attribute goes).&nbsp; The =
problem is=20
that this width includes the items outside the "viewport" and thus my =
columns=20
are too wide, resulting in the horizontal scroll bar on the=20
DataGrid.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for any help.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Kristin</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Craig Deelsnyder" &lt;<A=20
=
href=3D"mailto:cdeelsny@NOSPAMyahoo.com">cdeelsny@NOSPAMyahoo.com</A>&gt;=
wrote=20
in message <A=20
=
href=3D"news:e3oMzNwVDHA.1748@TK2MSFTNGP12.phx.gbl">news:e3oMzNwVDHA.1748=
@TK2MSFTNGP12.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Have you checked out the =
Control.ClientRectangle=20
property?</FONT></DIV>
<DIV><BR>-- <BR>Craig Deelsnyder<BR>Microsoft MVP - ASP/ASP.NET</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Kristin" &lt;<A=20
=
href=3D"mailto:kristin_barker@natureserve.org">kristin_barker@natureserve=
.org</A>&gt;=20
wrote in message <A=20
=
href=3D"news:%23kSeBatVDHA.1316@TK2MSFTNGP12.phx.gbl">news:%23kSeBatVDHA.=
1316@TK2MSFTNGP12.phx.gbl</A>...</DIV><FONT=20
face=3DArial size=3D2>How do I find out the size (specifically =
width) of a=20
listbox's (specifically datagrid) "viewport" where the "viewport" =
does not=20
contain borders (Fixed3D and otherwise), scrollbars, etc. =
?<BR><BR>Microsoft=20
defines a "viewport" in help text for the =
"DataGrid.VisibleColumnCount"=20
property as so: "The viewport is the rectangular area through which =
the grid=20
is visible."&nbsp; Well that's exactly what I need but where do I =
get it and=20
it's attributes?<BR><BR>I'm asking because I'm writing a method =
which fills=20
the width of a DataGrid with the columns defined in the active=20
TableStyle.&nbsp; The problem is that I can't get the width of the =
datagrid=20
which does not include the border, scrollbars, etc.&nbsp; =
<BR><BR>I've tried=20
the following and they all refer to the width of the ClientRectangle =
which=20
inclues scrollbars, borders, etc.<BR><BR>dataGrid.Width=20
<BR>dataGrid.ClientRectangle.Width <BR>dataGrid.Bounds.Width=20
<BR>dataGrid.DisplayRectangle.Width<BR>dataGrid.Size.Width<BR><BR>If =
I=20
allocate column widths such that the total of all column widths is =
equal to,=20
say, dataGrid.Width, I still get a horizontal scrollbar.&nbsp; The=20
difference between dataGrid.Width and this total of all column =
widths is the=20
width of say a 3D border, vertical scrollbar, etc.<BR><BR>Any=20
suggestions?<BR><BR>Kristin<BR><BR>Kristin Barker <BR>Principal =
Software=20
Engineer <BR>Email: kristin_barker@natureserve.org=20
<BR>http://www.natureserve.org =
</FONT></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_000B_01C35749.6FD75D00--


Re: DataGrid (or ListBox) "Viewport" Size by Craig

Craig
Wed Aug 13 00:50:26 CDT 2003

This is a multi-part message in MIME format.

------=_NextPart_000_00CD_01C36134.E2DFB050
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

From the remarks for ClientRectangle:

The client area of a control is the bounds of the control, minus the =
nonclient elements such as scroll bars, borders, title bars, and menus.

--=20
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET


"Kristin" <kristin_barker@natureserve.org> wrote in message =
news:%23HHI2r2VDHA.3088@tk2msftngp13.phx.gbl...
Yes. Control.ClientRectangle is inherited by DataGrid as the =
DataGrid.ClientRectangle and includes borders, scrollbars, etc.

BTW, I reread my original posting and should clarify that the sum of =
all column widths does in fact equal the DataGrid.Width (and all of the =
other names by which this attribute goes). The problem is that this =
width includes the items outside the "viewport" and thus my columns are =
too wide, resulting in the horizontal scroll bar on the DataGrid.

Thanks for any help.

Kristin
"Craig Deelsnyder" <cdeelsny@NOSPAMyahoo.com> wrote in message =
news:e3oMzNwVDHA.1748@TK2MSFTNGP12.phx.gbl...
Have you checked out the Control.ClientRectangle property?

--=20
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET


"Kristin" <kristin_barker@natureserve.org> wrote in message =
news:%23kSeBatVDHA.1316@TK2MSFTNGP12.phx.gbl...
How do I find out the size (specifically width) of a listbox's =
(specifically datagrid) "viewport" where the "viewport" does not contain =
borders (Fixed3D and otherwise), scrollbars, etc. ?

Microsoft defines a "viewport" in help text for the =
"DataGrid.VisibleColumnCount" property as so: "The viewport is the =
rectangular area through which the grid is visible." Well that's =
exactly what I need but where do I get it and it's attributes?

I'm asking because I'm writing a method which fills the width of a =
DataGrid with the columns defined in the active TableStyle. The problem =
is that I can't get the width of the datagrid which does not include the =
border, scrollbars, etc. =20

I've tried the following and they all refer to the width of the =
ClientRectangle which inclues scrollbars, borders, etc.

dataGrid.Width=20
dataGrid.ClientRectangle.Width=20
dataGrid.Bounds.Width=20
dataGrid.DisplayRectangle.Width
dataGrid.Size.Width

If I allocate column widths such that the total of all column =
widths is equal to, say, dataGrid.Width, I still get a horizontal =
scrollbar. The difference between dataGrid.Width and this total of all =
column widths is the width of say a 3D border, vertical scrollbar, etc.

Any suggestions?

Kristin

Kristin Barker=20
Principal Software Engineer=20
Email: kristin_barker@natureserve.org=20
http://www.natureserve.org
------=_NextPart_000_00CD_01C36134.E2DFB050
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>From the remarks for =
ClientRectangle:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>The client area of a control is the bounds of the control, minus =
the=20
nonclient elements such as scroll bars, borders, title bars, and =
menus.</DIV>
<DIV><BR>-- <BR>Craig Deelsnyder<BR>Microsoft MVP - ASP/ASP.NET</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Kristin" &lt;<A=20
=
href=3D"mailto:kristin_barker@natureserve.org">kristin_barker@natureserve=
.org</A>&gt;=20
wrote in message <A=20
=
href=3D"news:%23HHI2r2VDHA.3088@tk2msftngp13.phx.gbl">news:%23HHI2r2VDHA.=
3088@tk2msftngp13.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Yes. Control.ClientRectangle is =
inherited by=20
DataGrid as the DataGrid.ClientRectangle and includes borders, =
scrollbars,=20
etc.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>BTW, I reread my original posting and =
should=20
clarify that the sum of all column widths does in fact equal the=20
DataGrid.Width (and all of the other names by which this attribute=20
goes).&nbsp; The problem is that this width includes the items outside =
the=20
"viewport" and thus my columns are too wide, resulting in the =
horizontal=20
scroll bar on the DataGrid.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for any help.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Kristin</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Craig Deelsnyder" &lt;<A=20
=
href=3D"mailto:cdeelsny@NOSPAMyahoo.com">cdeelsny@NOSPAMyahoo.com</A>&gt;=
=20
wrote in message <A=20
=
href=3D"news:e3oMzNwVDHA.1748@TK2MSFTNGP12.phx.gbl">news:e3oMzNwVDHA.1748=
@TK2MSFTNGP12.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Have you checked out the=20
Control.ClientRectangle property?</FONT></DIV>
<DIV><BR>-- <BR>Craig Deelsnyder<BR>Microsoft MVP - =
ASP/ASP.NET</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Kristin" &lt;<A=20
=
href=3D"mailto:kristin_barker@natureserve.org">kristin_barker@natureserve=
.org</A>&gt;=20
wrote in message <A=20
=
href=3D"news:%23kSeBatVDHA.1316@TK2MSFTNGP12.phx.gbl">news:%23kSeBatVDHA.=
1316@TK2MSFTNGP12.phx.gbl</A>...</DIV><FONT=20
face=3DArial size=3D2>How do I find out the size (specifically =
width) of a=20
listbox's (specifically datagrid) "viewport" where the "viewport" =
does not=20
contain borders (Fixed3D and otherwise), scrollbars, etc.=20
?<BR><BR>Microsoft defines a "viewport" in help text for the=20
"DataGrid.VisibleColumnCount" property as so: "The viewport is the =

rectangular area through which the grid is visible."&nbsp; Well =
that's=20
exactly what I need but where do I get it and it's =
attributes?<BR><BR>I'm=20
asking because I'm writing a method which fills the width of a =
DataGrid=20
with the columns defined in the active TableStyle.&nbsp; The =
problem is=20
that I can't get the width of the datagrid which does not include =
the=20
border, scrollbars, etc.&nbsp; <BR><BR>I've tried the following =
and they=20
all refer to the width of the ClientRectangle which inclues =
scrollbars,=20
borders, etc.<BR><BR>dataGrid.Width =
<BR>dataGrid.ClientRectangle.Width=20
<BR>dataGrid.Bounds.Width=20
=
<BR>dataGrid.DisplayRectangle.Width<BR>dataGrid.Size.Width<BR><BR>If I=20
allocate column widths such that the total of all column widths is =
equal=20
to, say, dataGrid.Width, I still get a horizontal scrollbar.&nbsp; =
The=20
difference between dataGrid.Width and this total of all column =
widths is=20
the width of say a 3D border, vertical scrollbar, etc.<BR><BR>Any=20
suggestions?<BR><BR>Kristin<BR><BR>Kristin Barker <BR>Principal =
Software=20
Engineer <BR>Email: kristin_barker@natureserve.org=20
<BR>http://www.natureserve.org=20
</FONT></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_00CD_01C36134.E2DFB050--


Re: DataGrid (or ListBox) "Viewport" Size by Kristin

Kristin
Fri Aug 15 12:32:10 CDT 2003

Yes, that's the definition in the documentation, but consider the following
class containing a method to fill the datagrid with currently visible
columns. It works, but only by starting with ClientRectangle.Width (or it's
equivalent) and *subtracting* the width of the scrollbar and border.

I would love to remove the calculation of ViewportWidth if I just knew what
to use in it's place.

===========================

public class BetterDataGrid : DataGrid
{
...

public void FillWidthFromColumns (DataGridTableStyle tableStyle)
{
int totalColumnWidth = 0;
foreach (DataGridColumnStyle col in tableStyle.GridColumnStyles)
{
totalColumnWidth += col.Width;
}
// Determine the difference between the datagrid's viewport width
and the total column width
int toBeAllocated = this.ViewPortWidth - totalColumnWidth;
// this.ViewPortWidth is defined below

// Allocate that width over the currently visible columns
int count = tableStyle.GridColumnStyles.Count;
int allocation = toBeAllocated / count;
int leftover = toBeAllocated % count;
DataGridColumnStyle lastVisibleCol = null;

BetterDataGridTextBoxColumn btrCol;
// BetterDataGridTextBoxColumn supports attribute Visible (among
other improvemnts)

foreach (DataGridColumnStyle col in tableStyle.GridColumnStyles)
{
btrCol = col as BetterDataGridTextBoxColumn;
if (btrCol == null || btrCol.Visible)
{
col.Width += allocation;
lastVisibleCol = col;
}
}
if (lastVisibleCol != null)
lastVisibleCol.Width += leftover;
}

public int ViewPortWidth
{
get
{
// This isn't readily available so we'll calculate it from the
// dataGrid width and other control features.
int viewPortWidth = this.Width;
// this.Width is equalivaent to this.ClientRectangle.Width

if (this.RowHeadersVisible && this.TableStyles[0].RowHeadersVisible)
viewPortWidth -= this.RowHeaderWidth;
switch (this.BorderStyle)
{
case BorderStyle.Fixed3D:
viewPortWidth -= 4;
break;
case BorderStyle.FixedSingle:
viewPortWidth -= 4;
break;
case BorderStyle.None:
break;
}
if (this.VertScrollBar.Visible)
viewPortWidth -= this.VertScrollBar.Width;
return viewPortWidth;
}
}
}

===============================

Any thoughts?

Kristin


"Craig Deelsnyder" <cdeelsny@NOSPAMyahoo.com> wrote in message
news:eaL8Z7VYDHA.1900@TK2MSFTNGP10.phx.gbl...
From the remarks for ClientRectangle:

The client area of a control is the bounds of the control, minus the
nonclient elements such as scroll bars, borders, title bars, and menus.

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET


"Kristin" <kristin_barker@natureserve.org> wrote in message
news:%23HHI2r2VDHA.3088@tk2msftngp13.phx.gbl...
Yes. Control.ClientRectangle is inherited by DataGrid as the
DataGrid.ClientRectangle and includes borders, scrollbars, etc.

BTW, I reread my original posting and should clarify that the sum of all
column widths does in fact equal the DataGrid.Width (and all of the other
names by which this attribute goes). The problem is that this width
includes the items outside the "viewport" and thus my columns are too wide,
resulting in the horizontal scroll bar on the DataGrid.

Thanks for any help.

Kristin
"Craig Deelsnyder" <cdeelsny@NOSPAMyahoo.com> wrote in message
news:e3oMzNwVDHA.1748@TK2MSFTNGP12.phx.gbl...
Have you checked out the Control.ClientRectangle property?

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET


"Kristin" <kristin_barker@natureserve.org> wrote in message
news:%23kSeBatVDHA.1316@TK2MSFTNGP12.phx.gbl...
How do I find out the size (specifically width) of a listbox's (specifically
datagrid) "viewport" where the "viewport" does not contain borders (Fixed3D
and otherwise), scrollbars, etc. ?

Microsoft defines a "viewport" in help text for the
"DataGrid.VisibleColumnCount" property as so: "The viewport is the
rectangular area through which the grid is visible." Well that's exactly
what I need but where do I get it and it's attributes?

I'm asking because I'm writing a method which fills the width of a DataGrid
with the columns defined in the active TableStyle. The problem is that I
can't get the width of the datagrid which does not include the border,
scrollbars, etc.

I've tried the following and they all refer to the width of the
ClientRectangle which inclues scrollbars, borders, etc.

dataGrid.Width
dataGrid.ClientRectangle.Width
dataGrid.Bounds.Width
dataGrid.DisplayRectangle.Width
dataGrid.Size.Width

If I allocate column widths such that the total of all column widths is
equal to, say, dataGrid.Width, I still get a horizontal scrollbar. The
difference between dataGrid.Width and this total of all column widths is the
width of say a 3D border, vertical scrollbar, etc.

Any suggestions?

Kristin

Kristin Barker
Principal Software Engineer
Email: kristin_barker@natureserve.org
http://www.natureserve.org