VS 2003, .NET 1.1
I'm throughly puzzled here. I can't seem to get the method below to work...
private void AutoSizeHeight()
{
Graphics g = this.CreateGraphics();
int x, lineCount;
SizeF layoutSize = new SizeF(this.Width, this.Height * 100); // oversized
height
this.Height = (int)Math.Ceiling(g.MeasureString(base.Text, this.Font,
layoutSize, new StringFormat(), out x, out lineCount).Height);
g.Dispose();
// this.Height = 400; // this works
// this.Height *= 9; // this works
this.Height *= lineCount; // this doesn't work
}
//---------[end]---------------------
This method is part of an inherited TextBox control. It's purpose is to
resize the height of the control according to the height of the contents. It
works fine if I assign a constant value to height or multiply by a constant.
But when I try to multiply by lineCount it doesn't change. Height and
lineCount definately both have values but for some reason they won't
multiply.
I'm I doing something wrong or is there something strange going on?
Note: I don't know what it means, but the lineCount is red in the Watch
window... 2 1096
I am confused. In your text, you say that 'lineCount' definitely has a
value, yet the code you posted: this variable is not assigned.
What gives?
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Chuck Bowling" <ch**********@sbcglobal-NO-SPAM.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... VS 2003, .NET 1.1
I'm throughly puzzled here. I can't seem to get the method below to work...
private void AutoSizeHeight()
{
Graphics g = this.CreateGraphics();
int x, lineCount;
SizeF layoutSize = new SizeF(this.Width, this.Height * 100); // oversized height
this.Height = (int)Math.Ceiling(g.MeasureString(base.Text, this.Font, layoutSize, new StringFormat(), out x, out lineCount).Height);
g.Dispose();
// this.Height = 400; // this works
// this.Height *= 9; // this works
this.Height *= lineCount; // this doesn't work
}
//---------[end]---------------------
This method is part of an inherited TextBox control. It's purpose is to resize the height of the control according to the height of the contents. It works fine if I assign a constant value to height or multiply by a constant. But when I try to multiply by lineCount it doesn't change. Height and lineCount definately both have values but for some reason they won't multiply.
I'm I doing something wrong or is there something strange going on?
Note: I don't know what it means, but the lineCount is red in the Watch window...
If I understand correctly, the 'out' keyword in the MeasureString method
should assign a value to lineCount.
"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.com> wrote in message
news:KL********************@comcast.com... I am confused. In your text, you say that 'lineCount' definitely has a value, yet the code you posted: this variable is not assigned.
What gives?
-- --- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- "Chuck Bowling" <ch**********@sbcglobal-NO-SPAM.net> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... VS 2003, .NET 1.1
I'm throughly puzzled here. I can't seem to get the method below to work...
private void AutoSizeHeight()
{
Graphics g = this.CreateGraphics();
int x, lineCount;
SizeF layoutSize = new SizeF(this.Width, this.Height * 100); // oversized height
this.Height = (int)Math.Ceiling(g.MeasureString(base.Text, this.Font, layoutSize, new StringFormat(), out x, out lineCount).Height);
g.Dispose();
// this.Height = 400; // this works
// this.Height *= 9; // this works
this.Height *= lineCount; // this doesn't work
}
//---------[end]---------------------
This method is part of an inherited TextBox control. It's purpose is to resize the height of the control according to the height of the contents. It works fine if I assign a constant value to height or multiply by a constant. But when I try to multiply by lineCount it doesn't change. Height and lineCount definately both have values but for some reason they won't multiply.
I'm I doing something wrong or is there something strange going on?
Note: I don't know what it means, but the lineCount is red in the Watch window...
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John Brock |
last post by:
I have a base class with several derived classes (I'm writing in
VB.NET). I want each derived class to have a unique class ID (a
String), and I want the derived classes to inherit from the base...
|
by: Jon Davis |
last post by:
If I have a class with a virtual method, and a child class that overrides
the virtual method, and then I create an instance of the child class AS A
base class...
BaseClass bc = new ChildClass();...
|
by: RickDee |
last post by:
Please help, anybody.
I am trying to write a program so that it can launch an exe file ( which is
also genereated in C# ) and then simulate the button clicking and invoke the
methods inside the...
|
by: joeblast |
last post by:
I have a Web service that gets the financial periods and hold a reference to
a disconnected dataset built at initialization. Web methods work on the
dataset inside the web service. Everything is...
|
by: Don |
last post by:
I have a project wherein I derive a combobox and create a custom Populate()
method for it to fill it with objects of a custom class I also created in a
second project that the combobox project...
|
by: zzw8206262001 |
last post by:
Hi,I find a way to make javescript more like c++ or pyhon
There is the sample code:
function Father(self) //every contructor may have "self"
argument
{
self=self?self:this; ...
|
by: =?Utf-8?B?VHJlbnQ=?= |
last post by:
I have tied an AutoCompleteExtender to a textbox to indicate suggestions to
the user. Everything works fine if I utilize a webservice to fetch the
results. However, I want to put the web service...
|
by: Max2006 |
last post by:
Hi,
I am truing to find a pattern for my Business Logic Layer to be able to work
fine win ObjectDataSource's Update method.
The challenge is ObjectDataSource is not able to work with an...
|
by: cbmeeks |
last post by:
Hope I'm using the right terminology. Anyway, say I have a class
like:
class Animal
{
public double GetValues()
{......}
public void FilterBy(string text);
{......}
|
by: =?Utf-8?B?QkxVRVNUQVI=?= |
last post by:
Here is the link of the website
http://www.smartcharlotte2050.com/YourThoughts.asp
I have been told to change only the form action part of this site.which is
to "response.asp"
Here the method...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |