Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / June 2007

Tip: Looking for answers? Try searching our database.

Controlling row height in DataGridView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard Lewis Haggard - 25 Jun 2007 14:40 GMT
Here are the goals:

1) Give the user the means whereby a row's height expands to display the
entire contents of its tallest cell.
2) Give the user the means whereby a row will shrink down to a single line.
3) Give the user the means whereby a row's height can be manually set by
dragging the row header's divider.

I can accomplish either 1 and 2 or 3 but not all 3 at the same time.

The interface for goals 1 and 2 is handled through a column that has a
button in it. When depressed, the code sets the tallest cell's
Style.WrapMode = DataGridViewTriState.True. When released, the WrapMode
state is set to False. This works but only if the DataGridView is set up so
that row height drag is disabled. If row height drag is enabled then the
WrapMode appears to have no effect.

Would someone be so kind as to enlighten this rather confused programmer as
to which bits, flags and attributes must be set to what state in order for
the DataGridView to respond in the desired fashion? Thanks.
Signature

Richard Lewis Haggard
General: www.Haggard-And-Associates.com

Two fish are in a tank. One says to the other, "Are you absolutely position
that you know how to drive this thing?"
Please come visit here for a couple thousand good giggles!:
www.haggard-and-associates.com/Humor/humor.htm

AlexS - 25 Jun 2007 14:56 GMT
Probably you need to disable manual drag before setting 1 and 2. Then you
resize and enable manual resizing again.
HTH

> Here are the goals:
>
[quoted text clipped - 17 lines]
> as to which bits, flags and attributes must be set to what state in order
> for the DataGridView to respond in the desired fashion? Thanks.
Richard Lewis Haggard - 25 Jun 2007 16:50 GMT
Yeah, tried that first thing. There were problems. More information:

The app starts with the DateGridView in AutoSizeRowsMode =
DataGridViewAutoSizeRowsMode.None. This allows manual resize.

During expand/contract operation, the mode is changed to
DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders and then the cell's
WrapMode is set to True or False, depending. Upon completion, the grid goes
back to AutoSizeRowsMode of None.

There are problems with this. First of all, if the grid isn't forced to
immediately refresh, it ignores the row height changes. Even if it does the
refresh, the row height first expands and then contracts again.

Maybe I should try something slightly different - What are the sequence of
operations that the grid goes through to determine how tall the row has to
be? Since that works automatically, maybe I should just duplicate that
functionality and leave the system in a state fit for manual resize. I could
easily figure out the text extents for a normal text cell but that's not
what I'm using. I have created a RichTextBox column and this is the one that
can be the multi-line height. How do I figure out how tall a RichTextBox
cell needs?
Signature

Richard Lewis Haggard
General: www.Haggard-And-Associates.com
Please come visit here for a couple thousand good giggles!:
www.haggard-and-associates.com/Humor/humor.htm

> Probably you need to disable manual drag before setting 1 and 2. Then you
> resize and enable manual resizing again.
[quoted text clipped - 21 lines]
>> as to which bits, flags and attributes must be set to what state in order
>> for the DataGridView to respond in the desired fashion? Thanks.
Richard Lewis Haggard - 25 Jun 2007 19:45 GMT
I solved the problem of figuring out how tall a row must be to display the
entire contents of a RichText cell by creating a method that, when supplied
with a width, can calculate the height required to display RichTextBox's
contents. The single line contracted mode is satisfied by saving the height
of the new row when the form is first loaded. Thanks anyway, guys.
Signature

Richard Lewis Haggard
General: www.Haggard-And-Associates.com

911, what's the nature of your emergency?
"Oh my god! Please help! I accidentally shot my friend! It's really bad! I
think he may be dead!"
"Calm down, sir. This is important. Are you sure he's dead?"
The caller puts the phone down. After a moment, the 911 operator hears a
loud Bang
The caller returns. "OK, now what?"

Please come visit here for a couple thousand good giggles!:
www.haggard-and-associates.com/Humor/humor.htm

> Yeah, tried that first thing. There were problems. More information:
>
[quoted text clipped - 43 lines]
>>> as to which bits, flags and attributes must be set to what state in
>>> order for the DataGridView to respond in the desired fashion? Thanks.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.