Resizing Column In Datagrid
how do you resize a column of a datagrid to match the length of the text in it? and is it possible to change the style of the header to bold? thanks
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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
Not Allow Column Resizing
Hello,
I want to prevent users to change the size of a specific column. Does any one knows how can I do it?
Best regards,
Ricardo Amaro
ricardo.amaro@clix.pt
MSHFlexgrid Column Resizing
Is it possible to prevent the user from resizing a particular column mshflexgrid? ie I want the user to be able to resize rest of the columns, but I have a column which i have hidden(.ColWidth = 0) and I don't want the user to be able to drag and expand it at runtime. I know he/she has to delicately position the mouse and drag to be able to see it, but can I just not allow him/her to be able to resize?
Thanks in advance.
Flexgrid Column Resizing
Ive read the flexgrid functions in the knowledge base, but is there a simpiler way to do it such as .ColWidth or .CellWidth? I just want it to set each column to resize itself depending on the text at all times how is this possible?
Thanks
Jaden
Column Resizing In An MSFlexgrid
Hi All,
I need to resize the columns in my MSFlexgrid.
Note however, that I cannot use the controls AllowUserResizing property because I have merged headings in the first row which look like columnheaders so I can't click on the the first row to resize. I need it to work almost like excel where I can place the mouse pointer on the line that seperates columns and then change the width of the column.
Please help me.
ListView Column Resizing
Hi Everyone,
Is there anyway to disable column resizing inside of a ListView control? I would appreciate any help. Thank you.
Grid Column Resizing
Hey all,
Any ideas on resizing the grid columns when the form is resized!
The math for it!!
It's for a true dbgrid!
Cheers
Beacon
MSHFlexGrid Column Resizing
Hello,
Anybody know how to detect when a user drags between columns in a
MSHFlexGrid when resizing column width? (Short of setting up a timer event
that continuously monitors column width.) MouseDown, MouseUp, MouseMove,
MouseIcon etc. all seem to be 'blind' when my mouse cursor changes to the
horizontal double headed arrow for column resizing. No events seem to be
triggered when the mouse pointer is in this state?
Thanks,
Gord
Excel Column Resizing
Hello All Memebers
How can i adjust a certain Column or a row (Resize it) by a visual basic!!!
Is there is a code for making that?!
Thanks alot for help and advice
Egyptian Man
Table Column Resizing
Hi listers,
Does anyone know how to resize a field in a table in DAO/Jet (VB, Access).
I have a text field in a table and want to increase its length (the database exists).
I didn't find the equivalent for SQL command ALTER <table> MODIFY <column> ..
Thanks for replying
Listview Auto Column Resizing
I have a Listview control in Report view which I have populated with data.
Is there a way to auto-resize the columns in the Listview by code just like doubleclicking the line between the column headers does?
Prevent Column Resizing In A Listview?
Hello,
Is it possible to prevent column resizing in a listview? I still want to able to scroll down through the listview, but I cannot work out if it is possible to prevent the columns for being resized by the user - there does not seems to be a relevant property (I would have thought there would have been a AllowColumnResizing property).
Thanks in advance.
Capturing The Resizing Of A Listview Column
how do i capture the event when the columns in a listview are resized?
will i have to subclass? If so, can someone give me a starting point on how to do this, since i have never subclassed before.
thanks
DBGrid: Resizing && Column Control
I am using a DBGrid set up in the VB5 Form Wizrd. What I am going for is to have the columns within the grid resize themselves to the width of the largest entry loaded from the database. I then want them to resize themselves based on the size of the window if the user increases/decreases the dimensions.
Also, in Design mode there are only two columns present, however in Run Time there are 5. How can I edit those other 3 columns in Design mode and get them to show up? VB wont let me edit anything other than the first two.
Any help would be great. Thank you.
Restricting Column Resizing In A ListView
I have headers on my ListView, and don't want the user to be able to resize them. I've gone through every property I know of that seems like it could have anything to do with this and I can't find a way to lock the size of the columns.. anyone know of a way? If not, I can always hide the columns and build my own headers, I just don't want to unless I have to.
Column Width Resizing MSHFg
Here's my code
VB Code:
Do While Not rs.EOF MSHFlexGrid1.AddItem "" For lngCol = 0 To MSHFlexGrid1.Cols - 1 MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Rows - 1, lngCol) = rs.Fields(lngCol).Value 'If lngCol = 3 Then MSHFlexGrid1.Row = MSHFlexGrid1.Rows - 1 MSHFlexGrid1.Col = lngCol Select Case rs.Fields(lngCol).Value Case 8 To 10 MSHFlexGrid1.CellBackColor = vbGreen Case 4 To 7.9999999 MSHFlexGrid1.CellBackColor = vbYellow Case 0 To 3.9999999 MSHFlexGrid1.CellBackColor = vbRed End Select 'End If Next rs.MoveNextLoop MSHFlexGrid1.FixedRows = 1 MSHFlexGrid1.TextMatrix(0, 0) = "Employee Name" MSHFlexGrid1.TextMatrix(0, 1) = "Department" MSHFlexGrid1.TextMatrix(0, 2) = "Overall Score" MSHFlexGrid1.TextMatrix(0, 3) = "Rev Score" MSHFlexGrid1.TextMatrix(0, 4) = "GMD Score" MSHFlexGrid1.TextMatrix(0, 5) = "GMP Score" With MSHFlexGrid1 For lngCol = .FixedCols To .Cols - 1 For lngRow = .FixedRows To .Rows - 1 lngWidth = Me.TextWidth(.TextMatrix(lngRow, lngCol)) + 90 If lngWidth > lngMaxWidth Then lngMaxWidth = lngWidth End If Next .ColWidth(lngCol) = lngMaxWidth lngMaxWidth = 0 Next End With
And it is working fine on customer name and department, but the rest of the cols/data is 2 digit numbers, and it is resizing the cols based on that, rather than the fixedcols, which it seems to be skipping.
I've got the Fixedcols listed, but it should be resizing the last 3 cols to "Rev Score" length, but is instead using the nonFixed cols maxlength for the resizing.
Does anyone see where I went wrong?
Thanks-
Guph
Flexgrid And Column Resizing Resolved
hey,
2 questions here.
I basically want to be able to set the size of the columns in a flexgrid so the edges of my text isnt cut off.Now Ive found the code below on the forum that might be what I want but dont understand it fully.How is this function referenced.Is it called under a command button like Code:ChangeColWidth. And can anyone tell me what the value of ColNo would be.
Spankil Wrote
Code:Private Function ChangeColWidth(ColNo As Integer) As Double
Dim i, Max
Max = 0
With fg1
For i = .FixedRows To .Rows - 1
If TextWidth(.TextMatrix(i, ColNo)) > Max Then
Max = TextWidth(.TextMatrix(i, ColNo))
End If
Next i
ChangeColWidth = Max
End With
End Sub
If anyone knows a better way than this please tell me.
Also another question about Flexgrids.Can text (for example headers) be entered into the fixed row(the grey row) at the top.
Thanks.
Edited by - star84 on 6/25/2004 12:18:41 AM
:confused: Resizing A Flexgrid Column
Hi,
I am having a strange problem.I have a flexgrid in my program.I want the user to resize it.I tried using flexgrid1.AllowUserResizing = flexResizeBoth . But it allows the user to resize only in the row not in the column.I am using VB 6.0 , Office 2000 and Windows 2000.
Also can anyone tell me how to use the flexgriud so that my whole text is visble in a particular column that is it doesnt hide.I tried using flexgrid1.wraptext = false.But that doesnt help.
Can anybody help me out with my problem and suggest me what could be wrong !!!!!!
Regards,
Hema
ListView Column Header Resizing Cursor
Hello Everyone,
Is there anyway to know when the mouse cursor is located over a divider inside of the ListView column header? I have currently set a few columns so that they cannot be resized and would like the mouse cursor to stay the same as the default cursor for the columns that have been locked. I would appreciate any help. Thank you.
MSFlexgrid Control's Column Width Resizing?
Hi ,
Can I resize the MSFlexGrid control’s column width ?.When I run my program that use the MSFlexGrid,everytime the grid cols is the same size and some of my text in the grid isn’t visible.Is there any way to stop it?.Thanks...
Resizing A MS Flex Grid Column To Fit The Longest Value
hi,
I want to allow the user to dbl click on the column resize mark in order to resize it automatically to the longest value (makes all the values visible).
Same behaviour as in Windows Explorer and most of MS apps.
Is there a more elegant way of doing it other than going over each cell in the column and checking it's Width?
How do I catch the dbl click specifically on the resize mark?
thanx
Stop Column Resizing In List View
I want ot hide some columns of the list view.
And I want to Stop resing ONLY for first column of the list view
How can i do this..
Thankx in advance
Resizing A Column (based On The Longest Value) In MSHflexGrid Automatically?
Okay, I've been looking for a function or procedure that will automatically resize a column-width to the largest value within that column during runtime (like Excel, when you double click on the column line) using MSHFlexGrid....Is it possible to tap into a dll or write some code within VB 6 to do this? Any help would be greatly appreciated...
Morph
Resizing DataGrid
I need to change the size of the DataGrid when the Form is Maximized and Minimized. What is the best way to do this? I've tried several different things with no luck.
TIA,
James
How To Restrict The User Resizing The Column Of A List View Control
but my problem is, i have a hidden column in a list view control.(say as the 4th column).
now , at runtime if the user tries to increase the size of 3rd column, then my hidden column becomes visible.
to avoid that i want to restrict the user from resizing any of the columns of list view control.
thanks for any help, in advance
i found a third party control as a solution to this problem.
but i would like to know if there is any simpler solution.
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
Resizing Datagrid And MSFlexgrid
This can be done!
If you walk through the cols you can set the ColWidth property.
I can't use VB at the moment but it should be something like:
flexgrid.ColWidth(i) = xxx
where i is the column (start counting from 0!)
Good luck!
Need Help On Resizing A Datagrid Dynamicly
I was woundering if there is a way to resize the columns of a DataGrid dynamicly with the size of the text in them at run time.
I looked around on the the net and in my books and I do not see anything. Can someone tell me if and how this can be done.
Thank you
Resizing DataGrid Columns
I have a DataGris (as you may already know ), and would like to resize the columns to fit the text.
I wrote the following two routines, one that gets the widths according to the longest field in the recordset, and the other one that actually changes the sizes of the columns using the widths obtained from the other routine.
Nothing happens!!!!
Can someone please enlighten me ?
Code:
Public Function GetColWidths(ByVal grid As DataGrid) As Integer()
Dim Rowdatag, curRow, L, MyCols As Integer
Dim Myarray(20) As Integer
For Rowdatag = 0 To grid.VisibleRows - 2
curRow = grid.RowBookmark(Rowdatag)
For MyCols = 0 To grid.Columns.Count - 1
L = Len(grid.Columns(MyCols).CellText(curRow))
If Myarray(MyCols) < L Then
Myarray(MyCols) = L + 5
End If
Next MyCols
Next Rowdatag
GetColWidths = Myarray()
End Function
Public Function ResizeCols(ByVal grid As DataGrid, Myarray() As Integer)
Dim i As Integer
For i = 0 To grid.Columns.Count - 1
grid.Columns(i).AllowSizing = True
grid.Columns(i).Width = Myarray(i)
Next i
grid.Refresh
End Function
Then my call to the function is Code:Call ResizeCols(DataGrid1, GetColWidths(DataGrid1))
Resizing Datagrid Columns Automatically
Hi,
How would you resize the columns of a datagrid to be the size of the largest word in that column automatically when data is added to the datagrid.
Any example code out there, or links to tutorial for this problem would be great.
Thanks
Datagrid : Automatically Resizing Cells
Is there a way to resize cells in a Datagrid on the fly based on how much information is in each field in the database? Basically, I want the words to wrap if they exceed n amount of characters so there is no scrolling w/in the cell. (ie all text is visibe at all times)
Any help on this will be greatly appreciated. Thanks in advance.
Memory Reference Error When Resizing Datagrid
I have a datagrid on a tabbed dialog control. When I tried to resize the datagrid (I do not wish it to be resized - I was just playing with it), a memory reference error occured and the application crashed.
Does anyone have an idea why that happened?
Getting Strange Error After Resizing Columns In DataGrid
I have a datagrid that is bound to a recordset. When a user resizes the columns, I am saving the values of the width so they can be reapplied when the grid is refreshed.
Then, when a combo box value changes, I set those variables(width) to 0 and manually set the width of the grid. So this way, the columns will stay the size the user intends.
However, I am now getting a strange error. After I resize the columns, everything works great. When I change the combo box value, and then I try to open the recordset, I get
"error 3265: The item cannot be found in the collection corresponding to the requested name or ordinal". This error occurs when I try to open the recordset."
Very odd. It only happens AFTER I resize the grid, then try to open the recordset again. I'm using the same connection for the whole project and all recordsets, so I don't see why the connection would be "bad" all of a sudden.
I've even taken the query out of the code, but that runs fine in SQLServer, so it's not the actual SQL.
The recordset is closed when I'm trying to open it, so that's not a problem. Here is some code:
Column Resizing Setting Variables:
Private Sub dbgResp_ColResize(ByVal ColIndex As Integer, Cancel As Integer)
If ColIndex = 2 Then wid2 = dbgResp.Columns(ColIndex).Width
If ColIndex = 3 Then wid3 = dbgResp.Columns(ColIndex).Width
If ColIndex = 4 Then wid4 = dbgResp.Columns(ColIndex).Width
If ColIndex = 5 Then wid5 = dbgResp.Columns(ColIndex).Width
If ColIndex = 6 Then wid6 = dbgResp.Columns(ColIndex).Width
If ColIndex = 7 Then wid7 = dbgResp.Columns(ColIndex).Width
If ColIndex = 8 Then wid8 = dbgResp.Columns(ColIndex).Width
End Sub
Here is the code for when the combo box values change:
If cmbEntity.Text = "Clinic" Then
If wid2 = 0 Then dbgResp.Columns(2).Width = 5000 Else dbgResp.Columns(2).Width = wid2
If wid3 = 0 Then dbgResp.Columns(3).Width = 3000 Else dbgResp.Columns(3).Width = wid3
If wid4 = 0 Then dbgResp.Columns(4).Width = 2000 Else dbgResp.Columns(4).Width = wid4
If wid5 = 0 Then dbgResp.Columns(5).Width = 1000 Else dbgResp.Columns(5).Width = wid5
If wid6 = 0 Then dbgResp.Columns(6).Width = 1000 Else dbgResp.Columns(6).Width = wid6
ElseIf cmbEntity.Text = "Site" Then
If wid2 = 0 Then dbgResp.Columns(2).Width = 3600 Else dbgResp.Columns(2).Width = wid2
If wid3 = 0 Then dbgResp.Columns(3).Width = 2600 Else dbgResp.Columns(3).Width = wid3
If wid4 = 0 Then dbgResp.Columns(4).Width = 2000 Else dbgResp.Columns(4).Width = wid4
If wid5 = 0 Then dbgResp.Columns(5).Width = 1000 Else dbgResp.Columns(5).Width = wid5
'If wid6 = 0 Then dbgResp.Columns(6).width = 1000 Else dbgResp.Columns(6).width = wid6
ElseIf cmbEntity.Text = "Physician" Then
If wid2 = 0 Then dbgResp.Columns(2).Width = 1300 Else dbgResp.Columns(2).Width = wid2
If wid3 = 0 Then dbgResp.Columns(3).Width = 1300 Else dbgResp.Columns(3).Width = wid3
If wid4 = 0 Then dbgResp.Columns(4).Width = 3500 Else dbgResp.Columns(4).Width = wid4
If wid5 = 0 Then dbgResp.Columns(5).Width = 1000 Else dbgResp.Columns(5).Width = wid5
If wid6 = 0 Then dbgResp.Columns(6).Width = 1000 Else dbgResp.Columns(6).Width = wid6
If wid7 = 0 Then dbgResp.Columns(7).Width = 1000 Else dbgResp.Columns(7).Width = wid7
ElseIf cmbEntity.Text = "Site Staff" Then
Me.dbgResp.Columns(0).Visible = False
Me.dbgResp.Columns(1).Visible = False
If wid2 = 0 Then dbgResp.Columns(2).Width = 1300 Else dbgResp.Columns(2).Width = wid2
If wid3 = 0 Then dbgResp.Columns(3).Width = 1300 Else dbgResp.Columns(3).Width = wid3
If wid4 = 0 Then dbgResp.Columns(4).Width = 2000 Else dbgResp.Columns(4).Width = wid4
If wid5 = 0 Then dbgResp.Columns(5).Width = 3000 Else dbgResp.Columns(5).Width = wid5
If wid6 = 0 Then dbgResp.Columns(6).Width = 2500 Else dbgResp.Columns(6).Width = wid6
If wid7 = 0 Then dbgResp.Columns(7).Width = 1500 Else dbgResp.Columns(7).Width = wid7
If wid8 = 0 Then dbgResp.Columns(8).Width = 1500 Else dbgResp.Columns(8).Width = wid8
Else
If wid2 = 0 Then dbgResp.Columns(2).Width = 2500 Else dbgResp.Columns(2).Width = wid2
If wid3 = 0 Then dbgResp.Columns(3).Width = 2800 Else dbgResp.Columns(3).Width = wid3
If wid4 = 0 Then dbgResp.Columns(4).Width = 2000 Else dbgResp.Columns(4).Width = wid4
If wid5 = 0 Then dbgResp.Columns(5).Width = 1000 Else dbgResp.Columns(5).Width = wid5
End If
Any help would be great.
Thanks,
Drew
Add Column To Datagrid
Hi everybody; I hope one of you can help me.
I am displaying a table with a datagrid and want to add a column with the values from another table as it's contents.
Both tables have columns titled CODE. The second table has a field called TYPE that corresponds to the CODE (eg. CODE 101 means TYPE Maintenance). What I want to do is put the values of TYPE from the second table into the datagrid displaying the first table I'm not allowed to add a column into the table being displayed by the datagrid.
I'm connecting to the database thru Adodc (DISA for the first table; CODES for the second table)
I found this but when I try to populate the fields from the second Adodc (CODES) it doesn't work. I figure that's because the Datagrid1 is connected to DISA.
Private Sub AddColumn()
Dim c As Column
Set c = DataGrid1.Columns.Add(DataGrid1.Columns.Count)
With c
.Visible = True
.Width = 1000
.Caption = "type"
.DataField = CODES.Recordset.Fields("CODE").Name
'if i use .DataField = DISA.Recordset.Fields("WHATEVER").Name it
'puts the values from 'WHATEVER' into the column "type"
.Alignment = dbgRight
End With
DataGrid1.ReBind
End Sub
Any ideas?? Thanx in advance.
Set DataGrid.Column Value
Hi,
ive got a Problem with my data grid, i have a DataGrid where the Data Source is an DataEnvironment, allright it works, but now i want do add a column to that grid where i calculate fe: Column1 * Column2 but if i want to insert the value in the column with: DG.Columns(3).Value an error apears:
Column not found, |1
what have i to do to do that???
Column In Datagrid
Hi,
I have a datagrid that bind to a table. Some of the columns of the table are not editable. For those columns in the datagrid, I want to gray them out.
The datagrid property does not give enough tools for me to set up.
Please show me how.
Thank you,
Quang
Datagrid Column
On a form I have a datagrid...how do i specify the column width for each seperate column??
Datagrid Column
I don't want my identity column to show up in my datagrid. How do I control which columns I want visible and which ones I don't?
How To Add Column To Datagrid
Anyone know how to manually add a column to a datagrid.
The default value of the grid when you create the object is to only have two columns, I need 13. Thanks
Nightfox02
Datagrid Column Sum
I have a column in datagrid that displays all the prices. I want to sum up all the values from all the rows of that column and display it as a label. How can I sum up the data??
Thanks ... Bhavesh
Add Column To DataGrid
I am new to working with grids and cannot figure out how to add a column.
The grid is a DataGrid ActiveX Contol - Version 6.0. I can look at the
properties and code but cannot see where to add the column.
I appreciate your help.
Kevin
|