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?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
SGrid - When Changing To Different Column, Text Field Is Clipping The String
I've used an SGrid from VBAccelerator to create a Contact List. A combobox, or a textfield is displayed depending on which column the user selects. There are three columns in the SGrid called:
COL_CONTACTTYPE: Contact Type (combobox),
COL_CONTACT: Contact (textfield),
COL_CONTACTP: Contact Priority (textfield). I'm using the for the Contact List.
The relevant code is:
VB Code:
Sub cmn_tblContact_RequestEdit(tblContact As Control, cmbContact As Control, _ txtContact As Control, ByVal lRow As Long, ByVal lCol As Long, _ KeyAscii As Integer) Dim lLeft As Long Dim lTOp As Long Dim lWidth As Long Dim lHeight As Long tblContact.CellBoundary lRow, lCol, lLeft, lTOp, lWidth, lHeight lLeft = lLeft + tblContact.Left lTOp = lTOp + tblContact.Top + Screen.TwipsPerPixelY Select Case tblContact.SelectedCol Case COL_CONTACTTYPE ' Select the delimited list into the control: cmbContact.width = lWidth cmbContact.Left = lLeft cmbContact.Top = lTOp cmbContact.Text = tblContact.CellText(lRow, lCol) cmbContact.Visible = True cmbContact.SetFocus cmbContact.ZOrder 0 Case COL_CONTACT, COL_CONTACTP If tblContact.SelectedCol = COL_CONTACT Then txtContact.MaxLength = 20 End If If tblContact.SelectedCol = COL_CONTACTP Then txtContact.MaxLength = 2 End If If (KeyAscii = 0) Then txtContact.Text = tblContact.CellText(lRow, lCol) txtContact.SelStart = 0 If (Len(txtContact.Text) > 0) Then txtContact.selLength = Len(txtContact.Text) End If Else ' 31/5/06 David Lim Defect(General 18) - Prevent backspace character from being displayed. If (KeyAscii = 8) Then txtContact.Text = EMPTYSTRING Else txtContact.Text = Chr(KeyAscii) End If txtContact.SelStart = 1 If (Len(tblContact.CellText(lRow, lCol)) > 0) Then txtContact.selLength = Len(tblContact.CellText(lRow, lCol)) End If End If txtContact.Move lLeft, lTOp, lWidth, lHeight txtContact.Visible = True txtContact.SetFocus txtContact.ZOrder 0 End SelectEnd Sub
Defect: When I select a cell in the Contact Priority column (CONTACT_P), then select a cell in the Contact column (CONTACT), I notice that the text in the Contact column has been truncated. Eg. "1234" becomes "234".
Can anyone suggest what the problem is, and whether there's a possible solution? If you need any further information or clarification, please let me know.
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.
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
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.
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
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
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.
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).
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
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?
DBgrid Column Width
Hi, I posted a message the other day about change the widths of each column on my dbgrid. El_nino told me that I could do this by going to the custom option. The only problem was that I could only have two columns, is there any other way in which I could add more columns.
Thanks
DBgrid Column Width
Hi, how can I change the column width for each individual column because when I click on the dbgrid to show the properties it only lets you enter the same width for all the fields.
Thanks
Listview Last Column Width
Hi another simple one for you guys to help me with. Im using a listview and i thought there was a way to make the last colum automatically fill the whole of the remaing space.
Thanks
Dbgrid Column Width
Why does the Rollback method reset the column width to defaults? I would like to keep the user defined widths of columns...
ListView Column Width
I can't get the Column Width in a ListView to size to my requirements. Anyone else have the same problem ? Any help would be appretiated.
ListView1.ColumnHeaders(1).Width = 1000
ListView1.ColumnHeaders(2).Width = 3000
No matter what value I set it to , I get the same width when the form displays !
DBgrid1 Column Width
I'm trying to set the widths for the columns in a dbgrid1 unsuccessfully! How is this done?
Thanks
JO
Mshflexgrid Column Width
is there a way to programatically change the width of a mshflexgrid's columns widths to the width of the longest string in that column?
MSFLEXGRID Column Width
I've done this before but for some reason it's not working now. I have a MSFLEXGRID and I want to hid the last column so I did this:
CODETheGrid.ColWidth(18) = 0 'id
|