Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




DataGrid Column Width Value


What is the Column Width Value Type.....ie... Pixels, Spaces, Points? etc...




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
DataGrid Column Width Value?
In this expression...

DataGrid.Columns.Item(iCol).Width = 1000

What type is '1000'?
Is it a Pixel, char...number.....etc....i cant figure it out......

the reason for this is I have a MSflex grid which has a column width of 20...i would like to know how to convert that number to the equiv in a datagrid..Please any help would be great. Thanks in advance

Datagrid Column Width ????
I have two datagrids that are exactly the same. The only difference is that I am using them on different forms, and one of them has a filter.

My question is this.
On the first datagrid, I could write column widths like this
AppointmentsDataGrid.Columns("time").Width = 40
AppointmentsDataGrid.Columns("patient").Width = 150
AppointmentsDataGrid.Columns("Doctor").Width = 150
AppointmentsDataGrid.Columns("status").Width = 50
and the output was as I expected.

but then, on the second grid, when I write the same thing, the column widths get rediculously small. Is there a way of specifying the units used for the column widths that I have missed?

Jagdip

Datagrid Column Width
Hello everybody

I`m using a DataGrid component in my application. The Grid is being populated from an ADODB Recordset object. The problem is that some data fields are longer than the default width that the DataGrid components sets. How can I tell the DataGrid component to automatically adjust to the width of the data?

thx, in advance

George Papadopoulos

DataGrid Column Width
Bonjour Toute le monde!!!!
This is my first post and definitely won't be my last!

I'm a beginner and i've just created a DataGrid that is connected to a table in Access
using ADO (no ASP!). When i extract the data i need from the table, the columns have
a pre-defined column width.

My question is how do i set the column widths manually?

Also, the DataGrid appears on the screen as a grey box when the program is run up.
How do i get rid of the grid from the screen, so it is only shown when the data is output?

Any help much appreciated in advance!!!

Thanks
Koddy

AutoSize Datagrid Column Width
Hello all,

I'm just wondering what is the easiest way to autosize datagrid column's width such that when a new entry is add into the grid, the column width will adjust according.

--Simon

Changing Column Width In DataGrid
The following code will not work but I'm not sure why:


Code:
Private Sub Form_Load()
With DataGrid1
.Columns(1).Width = 3000
.Columns(2).Width = 4500
.Columns(3).Width = 4500
.Columns(4).Width = 5000
.Columns(5).Width = 6000
.Columns(6).Width = 4500
.Columns(7).Width = 5000
End With
End Sub

Yes, I do have a Datagrid with the name DataGrid1
I do have 7 columns but for some reason I get a Subscript out of range run-time error 9 at .Columns(2).Width???

Not sure...why? Please help

How To Change Datagrid's Column Width?
how to change datagrid's column width?

thanks

How To Resize Column Width Of DataGrid ?
Anyone knows how to resize each column width of DataGrid control in code ? Thanks

DataGrid ~ MSFlexGrid Column Width
Hi,
When using a Grid, and the user changes the column width, can I get the new
width of the column?

Thanks!

Setting Datagrid Column Width?
Hi,

I would like to set column widths in my datagrid at run time. I tried
DataGrid1.Columns(i).Width = xxx but it had no effect.

I also looked at the design time properties page but was only able to set
properties for columns 0 and 1.

Any suggestions will be greatly appreciated.

Thanks,
Lance

Set Column Width In Datagrid At Run Time
Using a datagrid control bound to a disconnected recordset, so many properties must be set at run time. I can't find any way to set the width of a single column, or set a single column to expand to contain the data. Any suggestions?

Column Width In Datagrid - Units Of Measurement?
I have a Datagrid with four columns. Two of the columns can be turned off (set to zero width). This works great !

I want to set the columns so they aren't in total any wider than the datagrid width. So what I did was set three of the widths, then set the fourth one equal to the datagrid width, minus the widths of the other three. Good in theory, but it doesn't work . Are the columns and datagrid measured differently?

Thank you in advance for your help!

Set Column Width For The Datagrid At Design Time?
hi all,

i just want to ask on how can i set column width for the datagrid at design time?

Detect DataGrid Column Width Changing In VB.Net
Hi, Everyone

I hope to know when the width of a datagrid column is changed.

In VB6, we have this: DataGrid_ColResize(ByVal ColIndex As Integer, Cancel As Integer)

In .Net, we don't have "ColResize" event any more. I found that when you changes the column width, click evnet is fired. However, click event is too general. It will also be fired when you select a row or click the title of a column.

Any idea ?

Peter

 

MSFlexgrid - Set Column Width To Text Width..
How do I set the column width to be = to the amount of text

(the text length varies)

Changing The Column Width To The Longest Text In A Column With The MSFlexGrid Control
hi all how do i change the width of a column to fit the text inside that column i am using the MSFlexGrid to show my data, with an adodb conenction
thanks from
mark

Set Column Width HELP
Anyone know how to set a column width to a fix number. I've tried

app.range("A:A").width = 50

but I'm getting an error. I don't want to do an AutoFit. I actually want it fixed.

Thanks in advance!

Column Width
When I load an Access database into a flexgrid...how can I get Visual Basic to pull up the format for each individual column width?
I'm sure Access uses a certain code to tell how much should each width be for each column.

If the above is not possible for Visual Basic...then maybe this is possible:
Go through each column and get the length of each cell...The one with the greatest length is set as an array(1-number of columns) Then format each column using a for/next statement.
The only problem and question for me is what is the right code to be able to do this?

I guess what would be good sample practice is a 2 column access file with two different lengths! And a visual-basic program that would load it into a flexgrid....but what is the code to format the width of each column? Any help on these two methods would be appreciated!!!

Kind regards,
Stephen

Column Width
Hi!

Can anybody tell me how can I define column width in MSFlexGrid table? For example, I would to set different widths each columns and, also different heights each rows.

Thank you forward,
Jovan

Change Last Column Width
I'm trying to get my last column in my MSHFlexGrid to fill the remaining space in the grid when the sum of colwidths are less than the grid.width.

For some reason I am getting a -1 value for the width when it falls out of the dispcol loop the first time and then 0 the next time. Both times, however, there are no changes to the grid's last column, even the the .ColWidth() value has changed...


Code:
Public Sub flxctlColPositions(ByRef myGrid As MSHFlexGrid, _
ByRef lstListBox As ListBox)
Dim dispcol As Integer
Dim flxcol As Integer
Dim lngSumWidths As Long
lngSumWidths = 0

With myGrid
'For each column to be displayed
For dispcol = 0 To lstListBox.ListCount - 1

'Look at each column of myGrid for match and reposition
For flxcol = 0 To .Cols - 1

If .TextMatrix(0, flxcol) = lstListBox.List(dispcol) Then

'Sum widths
lngSumWidths = lngSumWidths + .ColWidth(flxcol)

'Reposition column
.ColPosition(flxcol) = dispcol

End If

Next flxcol

Next dispcol

'Resize last column

MsgBox .ColWidth(lstListBox.ListCount - 1) 'Before change
.ColWidth(lstListBox.ListCount - 1) = .width - lngSumWidths
MsgBox .ColWidth(lstListBox.ListCount - 1) 'After change

End With
End Sub

Listview Column Width
Can someone show me how to set the column width in a Listview?


ListView1.View = lvwReport 'Set The Listview1 View so Columns/Headers can be viewed
ListView1.ColumnHeaders.Add , , "SCAC"
ListView1.ColumnHeaders.Add , , "Last Feed"

I can't get the above code to work when I add a width. The listview is blank when code is run.


I would appreciate any suggestions.

Thanks

Values For The Column Width
I'm trying the FlyGuy function to resize row height with word wrap in a MSHFlexGrid using a label in the form. During the debugging in the row:


Code:
myLabel.Width = .ColWidth(lCol)
I get .ColWidth(lCol)= -1 so it yields a "invalid value for that property" error.

Does it happen when the field is empty?!

Column Static Width
I created a form with macros and a width automatic adjusting code to prevent the width of the column to be changed accidentely. After further testings with my form, I uncovered a few problems with the manner I use to specify the column width. First when I select a couple of cells horizontally, and write something on the first cell, all the other columns will be sized as the first one. To undo that, I must write manually something in each column. Also, when I run my principle macro that does a lot of maths, loopings, copying cells etc. It seems to be hard for the processor because it seems the calcul required is raising exponentially.

So is there a way to set off those columns width sizing during the principle macro runs and then set it on, and making it checks after that if all the columns width is ok? Or Maybe it would be est to transform that width change column into a macro attached to a button and I would simply click on the bottun to resize corectly all the cells?

To help I will upload my xls program. The form is in the sheet "Formulaire" and to run the macro, press the button "UE et Loyers" which is located at the upper left of the form and add the identification code 114555 when asked by an inputbox. I'll also quote at the end an example of the wight code I use.
Thx!

http://agora.ulaval.ca/~jjdou/Loclis04sample.zip

Werner


Quote:





Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Select Case Target.Column
Case 1, 3, 5 To 8
Target.ColumnWidth = 2
Case 2, 4
Target.ColumnWidth = 7
End Select
End Sub

About Column Width Of A Listbox
Hi there. Any anyone please tell me how to adjust the width (by excel VBA codel) of a multicolumn listbox for each column ?

Cheers.

Flexgrid Column Width
Hi guys ,i am from Turkey .I couldn't find enough help sites from Turkey.My vb is not good and unfortunately my English is not good either. i hope i can tell my problem . i can't set the column widths permanently .need your help..
and i want to sum all number in the flexgrid and show in a textbox or label
and every changes of values in the grid must be shown on the label at the same time.

MSHFlexGrid Column Width
Is it possible to change the width of the columns in the grid? I don't see any property that allows it.

Getting Column Width In Listbox
How can I get the size (width) of a column in a Listbox?

Specifying The Column Width In A List Box
Is it possible to specify the individual column width in a list box (so that the columns have different widths to each other)?
If not, are there any tricks to getting around this?


<font color=blue> :: grin-r :: </font color=blue>

Flexgrid Column Width??
is there a way to set the column width? at runtime, i cant read the entire contents of some of my columns cause theyre too narrow

ta

Setting Column Width
I am using the MSFlexGrid and want to set the first Col width to be smaller than Col 2's width.

Here is the code I wrote:
With MSFlexGrid1
.Row = 0
.Col = 0
.ColWidth = ?
End With


What is a valid value for the column width in twips? I used 400 and I get a "Compile error: Argument not optinal" I never used twips before so I am not sure if they are looking for a numeric value or not...

Any ideas to set the column width?

Thanks,
Bill

Column Width In DBGrid
Does anyone know how to set the column width in a DBGrid at design time? I've been able to set the default width with the properties box, but I need to customize it so that when I run an SQL query to fill the grid all of my columns will fit on the form without a scrollbar. For example, some columns are only 2 characters wide and yet all the column widths are too wide and wasting space on the form. The form is a status form and the user doesn't have time for resizing.
Thanks,
Mike.

MSHFlexGrid Column Width
Hi. My problem concerns VB 6.0. I am using an MSHFlexGrid object to display data.

My problem is that the default column width does not fit the data. I have used the code shown at the bottom of this post to set the length to a multiple of the number of characters in the biggest box of each column, however, this doesn't give much luck as it's either too small or too big.

Can anyone offer me any advice/tips towards getting a best fit column width? Your help is much appreciated.


VB Code:
Dim fieldlen As IntegerDim maxlen As Integer For a = 0 To grdList.Cols - 1    grdList.Col = a    For b = 0 To grdList.Rows - 1        maxlen = 0        grdList.Row = b        fieldlen = Len(grdList.Text)        If fieldlen > maxlen Then maxlen = fieldlen    Next    grdList.ColWidth(a) = maxlen * 150Next

Excel Column Width
how to set the column width of a excel worksheet using vb

MSHFlexgrid Column Width?
Hi,

How can I alter the column width in a MSHFlexgrid so that it completely fits the data in it, and remains like that permanently?

Also how can I center-allign the headers in a MSHFlexgrid?


Thank you.

Listview Column Width
How do you modify a listview's column width at run time?

Set Column Width In LISTVIEW
Hi,

The Listview have serveral columns and it is in List report mode.

Try to do the following by add the column text and width, but no matter how I put in the width parameter, the column width is not change. any idea.


.ColumnHeaders.Add text:="Flag", width:=20
.ColumnHeaders.Add text:="Customer Name", width:=150
.ColumnHeaders.Add text:="Contact", width:=250

Thanks!

Listview Column Width
Hi all,

I want to emulate or get the functionality of when you double click between two columnheaders in a listview, how they resize the column to maximise the width according to the column data. There is no event built in as far as i've seen. Has anyone got any idea how I can do it?

Basically i'm loading data into the listview in report view when i form load and I want the columns to be maximised for the data on form load as well.

Thanks in advance.

Setting The Width Of A Column
Hi
I am exporting data from a recordset to an excel worksheet.I want the destination worksheet to have:
The width of the Column A set to 10
The width of the Column B set to 20
The width of the Column C set to 35
The width of the Column D set to 90
..

hOW can i do it?

Column Width In ListView!
I have a ListView with 2 columns. I want the width of the 1st column to be 3500 but even after specifying 3500 as the width of the 1st column in the ListView's Property Page (which comes up when Custom property is clicked in the Properties window) under the Column Headers tab, the width always remains the default i.e. the width refuses to change to 3500. How do I resolve this issue?

In fact, changing the width of the 1st column just doesn't make any difference; it always remains the same.

The view of the ListView is set to lvwReport & the ListView doesn't display the GridLines.

Flexgrid Column Width
I have some data going into a felxgrid and need the columnc big enough to be able to see the entire data being entered.

How would i do this?

Cheers
ILMV aka <insert aka name here>

Flexgrid Even Column Width
I have a flexgrid where the width stretches when the form stretches. Anyone know a formula to always make the columns a uniform size but stay within the grid size. So there are no scroll bars or paritally-viewable columns. I realize that to keep a uniform column size there will be a bit extra, but if I know the "extra" amount, I can add that to one of the coumns so that the columns always fit perfectly. (Acutally I want to calculate this so that each column has a minimum width, such that narowing the form width will scrunch the columns to their minimum, and expanding the form width will expand the column width to a point where there is a uniform column width--plus the extra).

Sgrid 2.0 Column Width
I'm using the following with www.vbaccelerator.com 's Sgrid control to set the width of my columns after I add them.
VB Code:
.AddColumn 1, "Low", ecgHdrTextALignCentre            .AddColumn 2, "High", ecgHdrTextALignCentre            .ColumnWidth(1) = .Width / 60            .ColumnWidth(2) = .Width / 60


I don't understand why I can't just use .Width / 2 to just have 2 evenly spaced columns. This doesn't make any sense at all. Is there something I'm missing? I've tried using the attributes in the AddColumn thing to make it work but nothing seems to work like I want. Can anybody help me?

Set MSHFlexGrid Column Width
Hi,

I would like to know how to know to set the width of the columns in the MSHFlexGrid.

My code is:
Public Function display_in_datagrid()
frmSendMMS.Height = 9315
frmSendMMS.Width = 14535
fraMMSStatus.Visible = True
If chckSchedule.Value = Unchecked Then
mms_status.RecordSource = "SELECT id1 as ID, sender, recipient,subject,status FROM mms_outbox;"
Else
mms_status.RecordSource = "SELECT id1 as ID, sender, recipient,subject,status, sending_time FROM schedule;"
End If
mms_status.Refresh
MSmmsStatus.Refresh
' Sleep (2000)
' MSmmsStatus.Width = 1.5 * 1444
End Function

Change The Width Of The Column?
is there a way to change the width of the columns of a listview control according to how long the text is? i have a set of text i want to input into the listview with different length, in different order.

How To Resize Column Width??????
hi guys,
does anybody know how to resize column width of a MSFlexGrid from the coding???

But if i went to the propaties and change the AllowUserResizing to "1 - Coloumns" then i can resize them in the run time. but i dont want to resize it in the run time. i want it to happen in the design time and i do not want users to resize it in the run time.

can i do this?????

thanx in advance,

regards,
Niroshan

MSFlexGrid Column Width
What is the correct way to set up the MSFlexGrid column widths so that a horizontal scrollbar does not show up?

For example, I have 5 columns and if I set

MSFlexGrid.ColWidth(i)=MSFlexGrid.Width/5

for all i from 0 to 4, then I get the scrollbar. So I guess I have to take the MSFlexGrid border width into account, but how exactly do you do that?

FlexGrid Column Width
Can someone help me change the width of my column depending on the text of the header? Or if that isn't possible, how can I change the width of a column with code? Thanks, Jeremy

HFlexgrid And Column Width
How do i set the row height of the Hflexgrid.?

And I need to have different widths for the various columns of my flexgrid?

Help me out?

Copyright © 2005-08 www.BigResource.com, All rights reserved