PC Review


Reply
Thread Tools Rate Thread

DataGrid text alignment problems: tall cells, right-truncation

 
 
Frnak McKenney
Guest
Posts: n/a
 
      19th Jul 2005
One of the reasons given for the Allied victory in WWI is that the
Nazi armament industry invested so much effort in creating new
weapons (e.g. the jet plane) it wasn't able to develop any of them
to the point of mass-production. There are days when I experience
the same difficulties with C# and dotNET: there are twelve ways to
do 'most _any_thing, and I wind up exploring six before I find an
acceptable solution. <grin>

Case in point: After reading Chris Sells' "Windows Forms
Programming in C#" I'm attempting to warp the DataGrid into a
scrolling three-column information presentation tool to replace an
older approach that was creating (and disposing of) large numbers of
controls (300-odd) on a panel.

With the help of Google and several kind Usenet posters I've managed
to get LinkLabel columns and read-only (uneditable) text columns,
but there are still some points where I could use some advice and/or
suggestions.

1) Right-justified text gets right-truncated (1/2-1 character).
This is a known bug with Labels (known to Usenet readers,
anyway), and the workaround (which I've used elsewhere) is to
tack a "\n" on the end of the text string.

If I were feeding the text directly into the cell there would be
no problem. However, my DataGrid is DataBound to a DataView,
and DataBe a problem. In this case I'm formatting a DateTime
column with "MMMM d"... so there's no place i can see to insert
a "\n". In fact, the VSdotNET documentation on DateTime
Formatting explicitly says this won't work... and when I tried
it anyway <grin> with "MMMM d \n" it only seemed to work
sometimes.

Anyone have any ideas on how I could get right ("Far") aligned
but untruncated text/dates in a DataGrid column?

2) My customer likes whitespace. Since at this point all of my
DataGridColumns are my code, extending the GetHeight() method to
make the cell taller is trivial (and it was nice to see the
other columns stretching to match). This gives me text and
link labels at the top of each cell, but I'd really like to have
them centered. Unfortunately, the DataGridColumn Paint methods
I'm overriding only seem to care about left/right alignment.

Is anyone aware of a way I could get my text up/down centered?

I have a third problem -- when I refresh the DataView this DataGrid
is attached to the DataGrid fails to find the new data -- but I
suddenly realized that I probably need to re-assign the refreshed
(but same-named) DataView to the DataGrid's DataSource. That is,
even if I only have one variable 'dv' I probably need to follow
_each_

DataView dv = RefreshDataViewForDG();

with a

dataGrid1.DataSource = dv;

Oh... Now that I've created my new DataGridColumn classes, it would
be really convenient if I could have them as selections in the
DataGrid DataColumnStyles dislog box, which seems to be "stuck" on
DataGridTextBoxColumn and (?)DataGridBoolColumn. Does anyone know
if this is possible?

Ah, well. It's late, and tomorrow will be a much better time to
inspect my feet for fresh bullet holes. <grin>

Any feedback will be appreciated.



Frank McKenney, McKenney Associates
Richmond, Virginia / (804) 320-4887
Munged E-mail: frank uscore mckenney ayut minds pring dawt cahm (y'all)
--
There is no avoiding war; it can only be postponed to the advantage
of others. -- Niccolo Machiavelli
--
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text Alignment in DataGrid Edit TextBox rn5a@rediffmail.com Microsoft ASP .NET 6 30th Nov 2006 02:28 PM
Text Alignment In DataGrid? Arpan Microsoft ASP .NET 7 1st Sep 2006 09:02 AM
DataGrid text alignment problems: tall cells, right-truncation Frnak McKenney Microsoft C# .NET 0 19th Jul 2005 05:05 AM
Datagrid Textboxcolumn Header Text Alignment Sam Microsoft VB .NET 0 7th Mar 2005 10:34 PM
DataGrid Header and Text Alignment =?Utf-8?B?UGFua2FqQmFuZ2E=?= Microsoft Dot NET 2 8th Jul 2004 02:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:41 AM.