Column Widths ???
Hi,
How do I allow the user to resize column widths in a datagrid but not exceed the visible width of the datagrid? I also need the columns not move the current selected column to the left (causing all the other columns, to the left of that one, to disappear out of the visible window).
Thanx in advance for any suggestions/assistance,
Jungo
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Specifying Column Widths?
Hi,
I have a data analysis program which outputs 8 rows and 20 columns of data into an excel file. However, I want to also provide the summary data on screen as well and I put a picture box and used the print command. The trouble is that only 14 columns of data fit in the picure box (window & picture box are maximised etc...). The space between the columns in the picture box are a bit too big so all i need to do is specify a smaller width between columns if that's possible. Here's the code that writes the data to the picture box.
PicSummary.Print "Summary"
For r = 1 To TotRun Step 1
PicSummary.Print r, 'no new line!
For i = 1 To 20 Step 1 'cycle through some bins
PicSummary.Print TotScore(r, i), 'no new line!
Next i
PicSummary.Print "|" 'new line!
Next r 'Loop the file
Anyone know?
Thanks in advance.
S.
Column Widths (VBA)
I have a spreadsheet with A:AA columns, for example, all with varying column widths. What I need to do in code is assign the current column widths to variable, then autofit the columns based on content and print, then be able to revert back to the original column widths. Any ideas? Some sort of array?
Pasting Column Widths?
I have a workbook with 15 sheets in it. One of these is called Produciton Profile. I have added a button to this which on pressing it will open a new workbook and paste the contents of this sheet into it and save it. All works EXCEPT the paste doesnt preserve the coloumn widths/heights of the origional. The following is my code.
ALSO I tried the line:
WScopy.Range("A1:H49").Copy Destination:=WSpaste.Range("A1:H49").PasteSpecial(xlColumnWidths, xlNone, False, False)
but xlColumnWidths seems to be wrong?
<vba>
Sub Button1_Click()
Dim WScopy As Worksheet
Dim WBpaste As Workbook
Dim WSpaste As Worksheet
Set WScopy = Worksheets("Production Profile")
Set WBpaste = Application.Workbooks.Add
Set WSpaste = WBpaste.Worksheets("Sheet1")
WScopy.Range("A1:H49").Copy Destination:=WSpaste.Range("A1:H49")
WBpaste.SaveAs ("t:profile" + Sheet13.Cells(1, 3) + ".xls")
End Sub
</vba>
MSFlexGrid Column Widths
Hi Guys,
Does anyone out there know how to get the column widths of a MSFlexGrid to resize themselves at run-time? Different columns need to be different sizes depending on how long the longest text for that particular column will be when displayed. Thanks in advance!
Datagrid Column Widths
I am using a datgrid, and looking for a way to "autosize" the column widths. Is this possible, or do I need to know the lenth of my data in order to set the column width?
Thanks
Column Widths In Listbox
This has been bugging me for quite a while, so how do you adjust the column widths in a list box? (Is it even possible?)
~MikeJ
Listbox Column Widths
Hi,
I have a list box that I populate from a listview using additem with vbtab's inbetween.
The problem I have is that if the text in a cell is long it pushes the next colomn over, and I would like to set column widths so this does not happen.
Ai am using
Dim tabs(7) As Long
tabs(0) = 20
tabs(1) = 50
tabs(2) = 90
tabs(3) = 199
tabs(4) = 300
tabs(5) = 330
tabs(6) = 360
which only specify the starting position, I assume?
Can anyone please help
Setting Column Widths Of A ListBox
I am using the code below to set the width of columns in a ListBox on a UserForm in Excel. However, I get the error "Could not set the ColumnWidths property. Type mismatch". Any thoughts?
Code:
Private Sub UserForm_Initialize()
ThisWorkbook.Sheets("Sheet1").Activate
colCnt = 2
Set rng = ActiveSheet.UsedRange 'Range("A3:B25")
With ListBox1
.ColumnCount = colCnt
.RowSource = rng.Address
cw = ""
For c = 1 To .ColumnCount
cw = cw & rng.Columns(c).Width & ":"
Next c
.ColumnWidths = cw
.ListIndex = 0
End With
End Sub
Changing Column Widths In Excel ...
I am opening Excel from my application, and am trying to format a worksheet to meet my spec., but VBA instructions don't seem to work well within VB. Can anyone tell me how I would perform any of the following :
(i) Column Sizing, i.e. col A = 8.43, col B = 11.57 etc.
(ii) Removing "Sheet2" and "Sheet3"
Any help much appreciated.
Thanks in advance .....
Adjusting Column Widths In MSFlexGrid
How would I programmatically adjust the column widths to fit the sizes of column titles, when the MSFlexGrid is populated with data.
Thanks - Vinay
Saving Listview Column Order, Widths Etc.
Does anyone know how to query a listview to find the column order and size? After I change the order and size of the columns, I would like to be able to save this information somewhere so when I open it up the next time it is in the order that I changed it to. How would I query the listview to have it return this information, how could I store it for when I would log on next time and how would I reorder the listview after I have loaded it with data from the saved information? Any suggestions would be greatly appreciated.
Ray
Automatically Changing Column Widths In Flexgrids
hi
i've got a routine to copy data from a databse file to a flex grid, but in some cases the column is too narrow and only part of the text in the field can be viewed, which is a problem as i will then be printing this table of data.
whats the easiest way to adjust column widths so that all the text in each cell can be viewed?
thanks
DataGrids And Adjusting Column Widths After A Query
I run a query using a command button on a form. The results of the query are used to populate a datagrid. I want to set the width of a specific column. Here is my code. Here is the code I think I need. I am not sure what to set it = to.
Code:
DataGrid1.columns(8).Width = ??
Also, I use the first field from DataGrid1 to populate data in DataGrid2 when it is clicked on. How can I always select the first column's value regardless of what field is clicked in that row?
Code:
Public Function ProjectTracking(strQSQL)
strSQL = "Select PT_NUM,NVL(CUSTOMER,'NA') as CUSTOMER,Cast(DUE_DATE as DATE ANSI) as DUE_DATE,Cast(REQUEST_DATE as DATE ANSI) as REQUEST_DATE,Cast(COMPLETED_DATE as DATE ANSI) as COMPLETED_DATE,REQUESTER,SUBMITTER,DESCRIPTION from PROJECT_TRACKING" & " " & strQSQL
searchRS.Source = strSQL
searchRS.CursorLocation = adUseClient
searchRS.CursorType = adOpenForwardOnly
searchRS.ActiveConnection = totalConn
searchRS.Open
If searchRS.EOF <> True Then
DataGrid1.Visible = True
Set DataGrid1.DataSource = searchRS
DataGrid1.columns(8).Width = ??
Else
retval = MsgBox("No Match", vbOKOnly, "No Match")
End If
End Function
Maintaining DataGrid Column Widths On Refresh
When 'refreshing' a largely wizard generated form, the datagrid columns return to the 'default' sizes. What would be the 'best practices' way to restore them/maintain them to what they were before the refresh?
Should 'column widths' be stored as part of user settings?
For example, I maintain window width and height as part of user settings (via database), should the column widths be stored in the same manner? Or is there a good reason to NOT store them?
Setting Variable Column Widths At Design Time
Trying to set column widths of a datagrip to different sizes at design. Able to set all columns to a certain width but would like to be able to vary the columns in the grid. HELP!!
Saving Array Of Grid Column Widths To Database?
I have an application which has an 2 ADO grids on a form into which multiple column databases are loaded. Whilst the application is running, the user can load different database tables into the grids. However, these tables will not all have the same number of columns (between 10 to 30 columns).
The user will nearly always want to modify the width of each column so that it looks good on screen but as each table is different, I am not able to predict what columns will be displayed.
So, what I want to do is allow the user to modify the column widths, the press a save button which will save the column widths in the database table so that the next time the user opens that table in the application, it recalls the columns widths previously saved, saving the user the tedious task of having to resize up to 30 columns every time they load that table.
I have an interim solution which saves the column widths to a dynamic array but this obviously loses the information when the application is closed.
Any suggestions?
Thank you.
CB.NET DataGrid - Stopping Users Changing Column Widths
I have a VB.NET 2003 application using datagrids and need to stop usersfrom
changing the widths of columns by grabbing header borders and draggingthem left or right.
I cant find any property that stops this.
Can anyone suggest a solution.
Rob
Resizing Column Widths In Datagrid Keeping All Visible
Hi,
How do I allow the user to resize column widths in a datagrid but not exceed the visible width of the datagrid? I also need the columns not move the current selected column to the left (causing all the other columns, to the left of that one, to disappear out of the visible window).
Thanx in advance,
Nilesh2
Edited by - Nilesh2 on 8/2/2003 8:05:10 AM
MSFlexGrid, Resize Event? For When You Resize Column Widths...
soz so many questions today
i need to make it so that when i resize one of the columns in the flexgrid it triggers an even to save the width of that column so it remembers it.
but there is no resize event, so how would i go about doing this? i have a feeling it probably wont be easy using the msFlexGrid....
HELP!! Border Widths
I have been attempting to solve this problem for some time and have not yet come across a solution
I use the following code to create a border around a user control
Code:
'save the border width
OldWidth = UserControl.DrawWidth
UserControl.DrawWidth = 1
'set the co-ordinates
X1 = 0
X2 = UserControl.ScaleWidth
Y1 = 0
Y2 = UserControl.ScaleHeight
'Draw a line. (B)=state that co-oridinates include oposite corners, (F)=fill the box
Line (X1, Y1)-(X2, Y2), vbBlue, B
'restore the original border width
UserControl.DrawWidth = OldWidth
What happens here is that the top and left borders are created but the right and bottom ones do not appear. Why??? I want to be able to create flat borders around the user control and be able to change the width YET have the borders the same width all around. If someone can sort this I would be eternally grateful!!
Vb Widths To Pixels >:O
hey im using a picturebox to grab the widths of text (picturebox.textwidth("...")) only it gives me the width in some other unit definately not pixels!(size 10 arial font width a 200+ width >_>) XD
so how can i get it to pixels :P
thanks ^_^
Font That Has An Same Widths For Each Letter
Hi all,
I am searching for a font that will give me same width for each letter so that multiple items added in the combobox can be aligned.
Please take a look at the following code:
dim intLenOfUid as integer
dim strSpcHolder as string
dim strUID_UName as string
dim intTemp as integer 'this acts like a constant
Do Until rs.EOF
intLenOfUid = Len(rs!Unit_name)
strSpcHolder = String(intTemp - intLenOfUid, " ")
strUID_UName = rs!Unit_name & strSpcHolder & rs!Unit_id
CmbUnitid.AddItem strUID_UName
rs.MoveNext
Loop
* the rs, cmbUnitid have been defined
In the combobox, the unit_id is not showing aligned after the calculation of the length of unit_name. Why is that? A reason I can only think of is each letter is actually different width. Am I correct?
Thank you very much for your help!
How To Change The Code To Specify Different Widths?
Hi,
I got one class module to print a listview. But the problem is with the coloumn widths. I need more width for Customer Name and less width for Invoice Number & Invoice Date. But with the following code I can print all the colomns with the same widths.
How can I modify the below code to specify the different widths. Please do help.
VB Code:
Private Sub ColumnWidth(objListView As ListView, intFontSize As Integer) Dim ColumnCount As Integer 'Set the array to match column header qtyReDim sngColumnWidth(objListView.ColumnHeaders.Count) 'Set the column widths (evenly spaced) based on # of columnsFor ColumnCount = 1 To objListView.ColumnHeaders.Count sngColumnWidth(ColumnCount) = (objPrinter.ScaleWidth / _ objListView.ColumnHeaders.Count) * ColumnCountNext End Sub
Regards,
Seema_S
Flexgrid: Can Gridlines Have Different Widths?
Hey everybody. Just a quick question today. Is there a way to make a single flexgrid gridline different than the rest? For my purpose, I have a 9x9 flexgrid, and I want to visually divide it into 9 3x3 boxes, so I would want to make the 3rd and 6th gridlines fatter than the others?
Possible? Not possible? Let me know. This is a very popular practice, and it's incredibly easy to do in Excel, so I have to imagine MS built it into the flexgrid control....
RTF Tab Widths [RESOLVED - Very Easy Too!]
Using VB6, WinXp.
Control is RTF
I couldn't find a solution on the board.
I know how to set the tabs and their positions.
But how do you set their widths.
Everytime a user presses the tab key it tabs to the next column.
But I want the tab widths to be smaller.... there to wide.
In MSWord you can use rulers and set the tabs.
How can I just set the default tab width of an RTF?
Thanks
Resizing Col Widths In Datagrid
Hi,
How do I resize column widths in a datagrid? I need them to be always fully visible and not move the current selected column to the left (causing all the other columns, to the left of that one, to disappear).
(i.e. DataGrid1.Columns.Item(3).Width =....etc)
Thanx in advance
Reeb
Screen Widths And Heights
OK I have a form that is maximized and I want to resize the controls inside it according to screen resolution.
I have been using Screen.Width and Screen.Height but these do not seem to take into account the taskbar etc. and therefore when I use them some controls are overlapped by the taskbar.
I thought I could use Me.Width and Me.Height but these are the values when Me.WindowState = 0 and therefore my conrols don't fill the page.
What I'm trying to find out therefore is some way of getting the inner width and height of a form when it is maximized - any ideas?
DJ
Make FlexGrid Remeber Col Widths
How Do I go About Making a MSFLexGrid Remember the Cloumn Widths the User has Adjusted Them To?
At Design Time the Grid is Set to FixedRows = 1, Rows = 2; FixedCols = 1, Cols = 2.
At Run Time Code Sets:
Total Cols to Recordset.Fields.Count + 1 (+1 to account for Fixed Cols) and;
Total Rows to Recordset.RecordCount + 1.
I have AllowUserResizing Set to Both. When the User Does resize this I want the program to remember the settings. The next time the form is opened, even if the Application has been shutdown, I want the cols set to that width.
Is this something I need to set in the registry.
Any Detailed help wiould be greatly appreciated.
Thank you.
MediaPlayer Heights And Widths Simple Question>
How does the mediaplayer ocx measure height and width
(msdxm.ocx). It has huge numbers in these fields im trying to center a video on my form using this
MediaPlayer1.Left = (Form1.Width - MediaPlayer1.Width) / 2
MediaPlayer1.Top = (Form1.Height / 2 - MediaPlayer1.Height)
but height and width of mediaplayer arent in pixels so it obviously doenst center right. help appreciated
Thanks Nick
Drawing Precise Line Widths In A Picture Box
Hi there, I need some help....
I am trying to redraw PCB gerber files into a picture box, reading the files is not a problem they are very basic.
The problem arises from the sizes of the lines and circles required in the drawing. To maximize the drawing the largest width and length are found by minusing the lowest and highest points used (all units are converted to millimeters if in inches). The result is assigend to the picture boxes ScaleWidth and ScaleHeight properties after being scaled up by 1000.
All the lines and points in the file are also drawn scaled up by 1000, now the problem I have is with the width of lines, the DrawWidth of the picture box can only be set in pixels. To set the DrawWidth to say 1.778 millimeters scaled up by 1000 is equal to setting it to 1778 pixels, this is far to large and the picture box just fills completely.
Now, I know if I had the picture boxes scale mode to twips then the calculation would be resoveld by setting the DrawWidth to say 1.778 millimeters times 1000 divided by Screen.TwipsPerPixel(X or Y) and this would scale it correctly.
Is there a way to calculate the number of my user scale points per each pixel, e.g. to say Screen.CurrentScaleModePerPixel(X or Y).
Or is ther another way to calculate an accurate drawing of a set of given X and Y coordinates.
Any suggestions will be greatly recieved and thank you in advance.
Word Table: Mixed Cell Widths ?
Please, help in this situation.
My Word-table has some splitted cells in a header.
I try to insert data to lower cells. But I have the message "Cannot access individual columns in this collection because the table has mixed cell widths. How to work with a table of such kind?
Thanks.
Concat Column Values From Multiple Rows Into A Single Column USING Mysql4.1
I"M USING MYSQL 4.1
I'm having two table like:
Doctor Product
1) Doc_ID Name 2) Doc_ID Product_Name
Doc_1 X Doc_1 p1
Doc_2 Y Doc_1 p2
Doc_1 p3
Doc_2 p4
Doc_2 p5
I'm joining these two table via query
Select Doc.Doctor_Id, Doc.Name, Prod.Product_Name from Doctor as Doc inner join Product as Prod on Doc.Doc_ID = PRod.Doc_ID
Result is:
Doc_1 X p1
Doc_1 X p2
Doc_1 X p3
Doc_2 Y p4
Doc_2 Y p5
BUT I WANT IT IN THIS WAY: WITHOUT USING THIRD TABLE
Doc_1 X p1,p2,p3
Doc_2 y p4,p5
CAN ANY ONE HELP ME OUT
Edited by - Macmillan on 6/9/2005 5:19:20 AM
How To Copy And Modify Listview Column Items And Put It In Diffrent Column?
Hi all i got a listview with first column has songIDs i want to for each item in songId column to take its value and add http://localhost/new/play.php?d=04&song= to it and to make it http://localhost/new/play.php?d=04&song=1234 and fill url column. But i do not know . could any one help me achive this .thanks
Save Single Column Array Into Variable Column Text?
So, I have an array with a couple thousand numbers that that represent values from a number of channels in one column. I'd like to put the numbers from one channel in one column. I have a listview that does that but now I'm trying to save the values into a text file. Right now to write them I have:
Open dlgSA.FileName For Output As #1 'dlgSA is the common dialog
On Error GoTo 0 ' turn off error handler
For K = 0 To arraySizeInSamps
Write #1, data(K)
Next K
Close #1 ' close the file
Exit Sub
The number of columns will be the same as the number of channels which is declared as: Dim numChannels As Long
Like I said before, my listView does have them separated in the correct columns but I can't figure out how to save that AS IS in a text or dat file.
Anybody have any ideas?
Thanks for your help.
Count No Blank Cell In Column AC Based Var In Column Y
With acode in VBA please....
How to count all non blank cells in column AC based a Var filled ="PUGLIA" and return the result of count in var My_count...
In thsi case the coun = 6
I use this formula but difficult to translate in VBA....
=MATR.SOMMA.PRODOTTO((Y3:Y1000="PUGLIA")*NON(VAL.VUOTO(AC3:AC1000)))
Simple Problem... 4-column CSV File -> VB 4-column Array
Hi,
I've got a simple question to most... but I've never used multiple-column arrays before (never could learn how to, mind-boggling!), and not really sure how to progress with this... not even sure if I should be using a multi-column array!
The CSV is like this (even with linebreaks):
392,3290,109
310,1900,490
390,1903,300
321,1033,610
and the CSV has 365 lines in it (one for every day of the year).
I am trying to get the data into an array so it also has an index, like this:
Code:
Index, Cost, Units, Time
1, 392, 3290, 109
2, 310, 1900, 490
3, 390, 1903, 300
4, 321, 1033, 610
This is the cost I use for importing the data into the program, and process into the array:
In the FOR loop, I want to 'index' the CSV file..
Code:
Public Sub GetCostTimeRatio()
Dim hFile As Long
Dim LocalFileName As String
Dim CostTimeRatioIndex(0 To 365, 0 To 365, 0 To 365, 0 To 365) As Long
Dim CostTimeRatioString As String
Dim CostTimeRatioLines() As String
Dim n As Long
LocalFileName = "Q: imeandcost.csv"
hFile = FreeFile
Open LocalFileName For Input As #hFile
CostTimeRatioString = Input$(LOF(hFile), hFile)
Close #hFile
CostTimeRatioLines = Split(CostTimeRatioString, vbCrLf)
For n = 0 To UBound(CostTimeRatioLines)
CostTimeRatioIndex(n,,,) = Split(CostTimeRatioLines(n), ",")
Next
Debug.Print CostTimeRatioLines(UBound(CostTimeRatioLines))
End Sub
But it says 'Can't assign to array' when I call the function, and it itemises the CostTimeRatioIndex as the culprit...
Help.... please...
Many thanks,
Gabba
Getting The Column Header Of The Selected Column In True DBGrid(5.0)
Hi Everyone,
I am new to VB and having a few problems with the code.
I have a true DBGrid(5.0) on a form.When i load the form,i bind the Grid to display values from a table in the Database onto the grid.What I am required to do is to be able to click on any column in the Grid and be able to sort them
(ascending or descending).
I am able to select the whole column by clicking on it.But How do I get the column header or the column number of the column what I select.I will be selecting only one column at a time. I tried finding the values of the column selected by using
colnumber =TestGrid1.Col in TestGrid1_Click event but it is not giving me the correct answer.
Could anyone help me with this...
Thanks,
--Veda
Dynamically Selecting Column By Excel Column Header (B, C... AD, AE, Etc...)
Hi Guys,
I am trying to automate a spreadsheet which would copy values from one worksheet, and insert it into another after manipulating the values slightly. I have managed most of the code (as shown below), however, I am struggling with the following:
The spreadsheet contains pricing information per supplier, and my aim is to retrieve the part number, size, and cost per part from the original into a new worksheet. As the cost column may be in a different location (based on multiple suppliers in the same worksheet), i need to prompt the user for the worksheet that contains the information and the column that contains the costs. I have already written the code to parse the worksheets and populate the combo box with worksheet names. Once a worksheet is selected, I need to parse all used columns and populate a combo box with the Excel column headers (e.g. B, C... AX, BE, etc...) so that the user can choose the correct column. Once the column is selected, I need to convert the column header to a column number (e.g. Col A = 1, Col F=6, Col BC = 46) so that I can copy the values via the GetRows() subroutine in the code.
Any help would be appreciated. Included below is the code that I have thusfar...
Thanks
-------------------------------------------------------------------------------------------------
Code:
Private Sub Worksheet_Activate()
' Get number of worksheets in workbook
cboWorksheet.Clear
' Get names of worksheets in workbook
For iCnt = 1 To ActiveWorkbook.Worksheets.Count
If ActiveWorkbook.Sheets(iCnt).Name <> "Data Unload" Then
cboWorksheet.AddItem ActiveWorkbook.Sheets(iCnt).Name
End If
Next
End Sub
Private Sub GetRows()
' Setup variables to be used
Dim strNewPart, strNewSize, strSheetName As String
Dim iRowData, sRowData, x, y As Integer
strSheetName = cboWorksheet.Text
For i = 1 To ActiveWorkbook.Worksheets.Count
If ActiveWorkbook.Sheets(i).Name = strSheetName Then
x = i
End If
If ActiveWorkbook.Sheets(i).Name = "Data Unload" Then
y = i
End If
Next
'Setup Variables in Use
iLastRow = ActiveWorkbook.Sheets(x).Cells.Find("*", , xlFormulas, , xlRows, xlPrevious).Row
sRowData = 6
Debug.Print "iLastRow = " & iLastRow
Debug.Print "sRowData = " & sRowData
' Loop through the data table and compare each record with data in the lookup table
' If a match is found, change the data table with what is in the lookup table
For iRowData = 8 To iLastRow
If Worksheets(x).Cells(iRowData, 1).Value <> "" Then
If Worksheets(x).Name = "Product X" Then
strNewPart = Worksheets(x).Cells(iRowData, 1).Value & "X"
strNewSize = "0.0"
Else
strNewPart = Worksheets(x).Cells(iRowData, 1).Value & "Z"
strNewSize = "0.0"
End If
Worksheets(y).Cells(sRowData, 1).Value = strNewPart
Worksheets(y).Cells(sRowData, 2).Value = strNewSize
End If
'increment Unload Counter
sRowData = sRowData + 1
Next
Worksheets(y).Select
End Sub
|