Moving Columns In A Datagrid
I am writing to a datagrid from a database, and all goes well. All of my information is displayed correctly. However, when the datagrid with all of the data is displayed I would like the user to be able to put the columns in the order in which he/she can besxt view the data. Can this be done? If I need to clarify more please let me know. Thanks.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Moving Columns In DataGrid In Realtime
Boss wants me to modify a program that uses DataGrid. He saw another program that allows the user to click on a column and drag it to the beginning column, thus moving the draged column to the new position.
Can this be done using DataGrid or is there another grid that comes with VB6 that will do this??
Moving Thru Columns ( And Worksheets )
Hi,
I am working on a macro in excel.
I wanted to read the contents of the cell which is 10 columns to the right of my active cell.
How can I do that.
Also I wanted to know how can I move the control from the current active cell to a particular cell in a different worksheet.
Please suggest a method
amol
Listview, Moving Columns?
Well, i cant really explain the title in just a few words. I want to add 2 more rows to my listview, but i dont want to add them at design time (alot of code to change then).
The problem is, that i want the two rows that i add, i want to move them so they are positioned in-between two columns that are already there.
So, i added rows 12,13 to my listview during design time. I want 12 and 13 to appear to be inbetween columns 1,2.
Hope it makes sense
Moving Columns On A Listview (Report View)
I want to programmatically set the Position of the columns in a list view.
This is an "after thought" so I am trying to do it on already loaded listviews.
I see from a little experimentation that I can easily move the column headers by simply changing the .position property.
But that does not bring over the data for that column. (Just the header)
Do I have to manually move the data or there an easier way?
(By "manually move the data" I mean set up a temp array, copy the column's data, update new column after moving other column into original col number)
Regards,
Datagrid Columns
How do I make more columns? There are only 2 to begin with and I do not see anything in "Properties" to make new columns. Also how would I take the data from a datagrid and enter it into a database?
Datagrid.columns
I'd like for users to be able to click on a column then sort asc or dsc. What method will let me know what column has been clicked?
Datagrid.columns
is there a way to resize individual datagrid columns and then save resized settings.
Columns In Datagrid
Is there any way of controlling which columns are shown (and the size of columns) in a datagrid. I only need to do it at design time but can't find the property. Tried using tablestyle collections but nothing seems to happen at run time!
Any ideas?
Datagrid Columns
I want to change color for one column of a datagrid, How can I do that?
DataGrid Columns
How do I move columns around a data grid ?
For example, I want during runtime, to move the first column, 3 columns to the right.
Thanks,
Yaron.
Resize Datagrid Columns....
Is there a way to autosize Data grid columns to the text that is in them?
Similar to the way it can be done in a listview......
Locking Columns In A Datagrid?
Hi all,
I'm using a datagrid control to present data to the user, but I only want the user to be able to edit certain columns. Does anybody know how to lock or stock a user from editing columns in a datagrid?
Thanks,
Phil.
Hiding Datagrid Columns
I created an application with a datagrid and textboxes on a form. The datagrid and textboxes are bound to the same data set from a data adapter, using an Access data base. So when you navigate through the datagrid information, the textboxes also show the corresponding fields. My problem is, I want the datagrid to only show a few of the columns, and just have the rest of the information in the textboxes. I tried looking up hiding or deleting columns in vb help, but none helped. It had information on adding columns and something about a tables style collection and gridcolumns style, but that is all empty in mine. I know I can get rid of columns in the data adapter but that means I cannot access that information for the textboxes. I hope I am making enough sense, but any help would be greatly appreciated! I know hiding columns is easier for web apps, and apparently there's a datagrid property builder thing for that, but a stupid windows form is much more complicated. Thanks in advance!!!
Customize Datagrid Columns
Hi..
I am trying to load a datagrid from a recordset. I need to load a couple of columns from the datagrid instead of all. can anybody please help me set the field values of the datagrid.
Each customer file has 120 values that I need to display as a grid of 10 X 12 cells.
first I tried to have all 120 values in one column. but the grid will display all these values in one column. ("IF anybody can help me show all these 120 values in sets of 12 per column then my problem ends")
then I modified the table to 10 columns of 12 rows each for a customer file..but it displays all the values in the table for all the customerfiles instead for one customer.. plz help
I am unable to set the fields from recordset.
code that im using
Call DataOpen(goConn) 'opens connection to database
Dim CustomRS As New ADODB.Recordset
' sql statement to select records for a aprticulat customer file name.
strFileValue = frmMainRPM.dcoFile.Text
strCustomFile = " [RATE_FORECAST].FileName Like '%" & strFileValue & "%'"
strCustom = " Select * from RATE_FORECAST where " & strCustomFile
'Open recordset
CustomRS.Open strCustom, goConn, adOpenForwardOnly
'Sets the fields from the recordset
DataGridRateForecast.Columns(1).Text = CustomRS.Fields("Value1").Value
DataGridRateForecast.Columns(2).Text = CustomRS.Fields("Value2").Value
DataGridRateForecast.Columns(3).Text = CustomRS.Fields("Value3").Value
DataGridRateForecast.Columns(4).Text = CustomRS.Fields("Value4").Value
DataGridRateForecast.Columns(5).Text = CustomRS.Fields("Value5").Value
DataGridRateForecast.Columns(6).Text = CustomRS.Fields("Value6").Value
DataGridRateForecast.Columns(7).Text = CustomRS.Fields("Value7").Value
DataGridRateForecast.Columns(8).Text = CustomRS.Fields("Value8").Value
DataGridRateForecast.Columns(9).Text = CustomRS.Fields("Value9").Value
DataGridRateForecast.Columns(10).Text = CustomRS.Fields("Value10").Value
'optRateForecast(0).Value = True
'DataGridCustom.Enabled = False
End Sub
Hiding Columns In ADO Datagrid
Hi
I am trying to hide a column in ADODB datagrid..
Code
sub form_load()
Me.DataGrid1.Columns(0).Visible = False
end sub
I do not want users to see the column but I want the data from it..
How To Calculate Datagrid Columns
Hello all,
i want to know how to calculate fields in datagrid colums and get the result in other colums.
Anyone can give me some idea ??
Thanks
DataGrid Headers / Columns
Hi all,
Visually i need to highlight some columns in the Datagrid which are enabled for Sorting so that when the user click that Header the entire column get sorted.
Example : Col1 (is sort_enabled) , Col2, Col3, Col4 (same as Col1) is it possible to highlight in anyway Col1 and Col4 ?
thanks !
alex
Hiding DataGrid Columns
In attempting to hide a Primary/Foreign Key column in the datagrid I have exposed myself to another problem. I can successfully hide the columns after reading this MSDN Article, but I am no longer able to use these "hidden" values. The way I was going about using the Columns before they were hidden was to get the current row/ current column index and then pass this information to a routine...etc. Now, since these columns are no longer visible, my poorly designed process now doesn't work as expected. Here is a sampe of the code:
Here is how I have been hiding the columns:
Code:
ds.Tables("Results").Columns("RecordID").ColumnMapping = MappingType.Hidden
Here is the code that would get the values in the columns if they are SHOWN, but not hidden:
Code:
callingform.LoadNewRecord(Me.dgdResults.Item(Me.dgdResults.CurrentCell.RowNumber, 0).ToString, Me.dgdResults.Item(Me.dgdResults.CurrentCell.RowNumber, 1).ToString)
What is a better and more efficient way to approach this so I can hide the columns and still use the values behind the "hidden" columns?
Thanks in advance for your guidance!
Columns Not Showing Up On Datagrid
I've been having a problem where all the fields I select from a database, aren't showing up in my datagrid. Right now all I can seem to get are 2 columns to show up and the others don't even have a blank column or anything. What am I missing here, why aren't they showing up? I can't seem to find a field in the datagrid properties that specifies how many columns there should be. Can soemone help me out? Here's the code that I'm using right now.
Code:
Public Sub LoadNotes()
lngProspectID = txtProspectID.Text
Debug.Print lngProspectID
Set cn = New ADODB.Connection
cn.CursorLocation = adUseClient
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=database.mdb;" & _
"Persist Security Info=False"
Set rs = cn.Execute("SELECT * FROM tbl_prospect_notes WHERE prospectID = " & lngProspectID & " ORDER BY noteID")
With DataGrid1
Set .DataSource = rs
.Columns(0).Caption = "Note ID"
.Columns(0).DataField = "NoteID"
.Columns(1).Caption = "Prospect ID"
.Columns(1).DataField = "ProspectID"
'.Columns(2).DataField = "UserLoginName"
'.Columns(3).DataField = "NoteDate"
'.Columns(4).DataField = "NoteTime"
'.Columns(5).DataField = "Note"
' here is where you put the formatting stuff for
' the datagrid (font sizes, headers, column widths, etc.)
End With
End Sub
Datagrid Adding Columns
this is a really silly question, but i seriously dont know how to do it. How do i add a new column to a datagrid. It starts off with two, and all i want to do is add two more columns to it. why am i finding this so difficult! Isnt there just some option in the properties that lets you do this?
im using vb6.
Thank you.
Hide Columns In DataGrid
Dear friends,
I have 5 fields in Table Items.I created DataGrid to view the table.
I have 5 cols. as follows.
code,name,uom,desc and stock.
But I don't want to display all the columns.I want to display only
code,name and stock.How to hide other cols, Please help me to do!
Locking Columns In A Datagrid
I'm trying to lock the first column in a datagrid but not having any success.
This is what I'm using, is this right?
VB Code:
Private Sub Form_Load() grdDataGrid.Columns(0).Locked = True End Sub
Thanks guys
Reordering COlumns In A DataGrid
I have a DataGrid control that is bound to an ADO data source. I have assigned the fields, caption and format to the columns at design time. Is there a way to allow the user to reorder the columns at design time? For example, move column 3 to column 1. column 1 would then become column 2 and so on.
DataGrid - Resize (not Columns) - Help Please
Hi,
I am trying to resize my datagrid on screen, so when you change the size of the form, everything expands to fill it. This is all fine except the horizontal movement of the datagrid, the vertical expansion is fine (i.e. always keeps 120 distance from the bottom). All my other code works fine!
Thanks in advance for your help.
Paul.
VB6/W2K
How To Move Columns In ASP.net Datagrid
I have datagrid control on webform(ASP.NET C#).I have populated it with database values through Dataset.
Datagrid have columns Name,Company,Phone and Email(in the order)
Now I want to move the columns on respective button clicks like
I want move the Phone Column to the First column on PhoneButton_Click.and like wise for all 4 columns.
How to do it?(only on WEBFORMS not in VB.net or C#.net Windows Forms)
Summing Columns On A Datagrid
I have a datagrid that has number of rows. The columns are all numbers and I want to generate a total for each column as well as each row...
like this
Column1 column 2 column 3 total
1 1 1 3
2 1 1 4
1 2 .5 3.5
total 4 4 2.5 10.5
My problem is moving down the rows. I cannot find a move next or set row or anything else that lets me down the grid. I can detemine how many rows I have by Approxcount, but not how to move.
Any ideas?
Thanks
Hide Columns In Datagrid
Hi! i use a recordset to set datagrid datasource.
as below,
rs.open "select ID,name,Desc from table" 'rs recordset
set dg1.datasource=rs 'datagrid dg1
My problem is how to hide 'ID' field from the datagrid.
I dont want to display that column.
I know there's a property named 'visibleCols' in datagrid.
it gives the number of columns displayed. How can i put it
to use to hide a column. Any other alternative too will be
great!.
thnx
Mur.
Combining Two Columns In A Datagrid
I have a datagrid that I create from a query on a database. In this
datagrid are two columns, appTimeHour and appTimeMin for the hour and
minute of the appointments.
I would like to create a new column called Time, where I combine these
two columns into one. How can I do this?
Any help would be greatly appriciated
Jagdip Singh Ajimal
Autorisize All Datagrid Columns
hi,
i am using datagrid im my project but i have some problems.
when i run an sql command which selects 6 columns these columns fits the datagrid but when i run an other sql command which selects 3 columns it does not fit the datagrid.Then half of the datagrid is empty.
Is it possible to autorisize the size of the columns to fit the datagrid??
Combine Columns In A DataGrid
How can I combine two columns (i.e., LastName and FirstName) from a DataSet into one Column in a DataGrid (i.e., "FullName")? The DataTable ("Agents") in the DataSet has the FirstName and LastName broken out in two separate columns, but I would like the user to see one column called FullName (e.g., "Smith, Alan") instead of two separate columns. If the user wants to edit the name, I can have him/her go to a separate form where the names are broken out.
Would this pose a problem for table updates? For example, the first column could be the combined name ("Smith, Alan") and the next column can be an check box to change active status. If the user updated the "status" in the DataGrid, would the combined column present a problem in the Update method?
thanks in advance.
Jay
DataGrid Is Limited To 2 Columns??!
Hey there guys,
I have a very dumb question but i can't figure out why DataGrid control can't have more than 2 columns? Do you know how to increase the number of columns?
Thanks,
X3M
How To Format Columns In Datagrid?
I'm using an ADO control and datagrid to access a text file. I want to set the column formats at run time. I'd like to do it at form load. I'd do it at design time, but I can only set columns 0 and 1 through the properties page.
Private Sub Form_Load()
With dtgRegister.Columns
.Item(0).Caption = "Check #"
.Item(0).Width = 732
.Item(1).Caption = "Date"
.Item(1).Width = 812
.Item(2).Caption = "Vendor"
.Item(2).Width = 1692
.Item(3).Caption = "Notes"
.Item(3).Width = 1670
.Item(4).Caption = "Debit"
.Item(4).Width = 720
.Item(5).Caption = "Credit"
.Item(5).Width = 720
.Item(6).Caption = "Status"
.Item(6).Width = 512
.Item(7).Caption = "Balance"
.Item(7).Width = 732
End With
End Sub
Totaling Up Columns In A DataGrid
Is there a special way to total up columns of data in a DataGrid after the DataGrid has been populated with records from a query run from a SELECT statement? The code I used keeps coming up with a invalid row number error. I am using ADO connecting to a table in a MS Access 97 database. Let me know if you need to see my code. Thanks DAVE
Edited by - wheels on 11/5/2002 9:53:11 AM
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))
DataGrid Columns BackColor
I would like to change Backcolor for one column in my DBGrid.
Is't possible
I think i'ts was possible with MSFlexGrid but with the DBGrid ???
Thanks
Redg
Number Of Columns In A Datagrid
Is it time for me to turn off my computer and get some sleep, or is it just impossible to set the number of columns of a datagrid (VB6, OLEDB) at designtime. It only has two columns, and I can't seem to find a place to add any.
Validating DataGrid Columns
Hi,
I have a Datagrid bounded to a SQL 7 database.
My Datagrid has 3 columns: Code, Name and Age.
Code must be greater than zero, Name must be not null and Age must be greater than zero.
How can I validate the content typed by the user of each column? What events should I use?
Thanks in advance,
Michel Jr.
Some good Activex controls at my HP:
http://www.geocities.com/michel_junior_hp/index.html
DataGrid.Columns(i).Button
Its written in the help that when set
DataGrid.Columns(i).Button=True
a button will displayed in the upper right corner of the current cell at run time.
But what i get is a solid line to the left edge of the cell all over DataGrid,and the buttton is displayed in the left side of the cell not in the upper right corner as mentioned.
Any help about that ,,,
thanks in advance
Moving To Next Row In Datagrid...
Hi all,
I am using Vb6.0.
I display only one column in datagrid. I want to move to next line when user preses either enter or down arrow or tab.
I am copying amount entered in keypress event.
Private Sub grdChkAmts_KeyPress(KeyAscii As Integer)
If ((KeyAscii = vbKeyReturn) Or (KeyAscii = vbKeyDown)) Then
cAmt = grdChkAmts.Text
End If
End Sub
Then update table :
Private Sub grdChkAmts_AfterInsert() '*************WORKING Fine********
conBreakdown.Execute "UPDATE tbl_CheckAmounts SET User_ID = '" & strUserName & "' " _
& " WHERE Amount= " & cAmt
End Sub
With existing code when i press enter and then down arrow the cursor is moving to next row.
I need help with this.
Thanks for any help
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Edited by - sreddy on 8/15/2007 12:02:24 PM
Datagrid Columns! Exporting To Excel.
HIYA PPL, ive been trawling through all the posts here but still havnt seem to have found a complete answer anywhere.
i'm pretty new to vb.. i was required to link acces db to VB6.. no probs there.. ado handled that fine
I know need to export the contents of a datagrid to excel and create a chart.. preferably so the chart is made on a click of a vb button.
(it is a datagrid not msflexgrid)
i've tried using the code i found but i cant get newhere coz theres bits missin that i just cant fill in..
I can get the code to open excel and a new work sheet and even a chart.. set grid titkes legends etc..
just dont know how to select the colums i want from my datagrid??
Anyone help?? much appreciated
Sums Of Rows And Columns In Datagrid?
i've got a datagrid on a form. it's based on a table from a connection to an access database (a "DataEnvironment" connection). i'm kinda new at this.
the data in a row on the grid (and in the table) is a text field, and then 7 fields for hours/day. i wanna show a tally for each row for all the hours, and then a total for all hours in all rows. i'm not sure at all where to begin... can i add an unbound column to the grid, or add another grid based on some different requests from the database that is updated when the first datagrid is changed?
some fingers pointing, however specifically, in the right direction would really help me out.
Quick Question Regarding Columns In A Datagrid
Yes I know, datagrids seem to be a popular subject for me, lol. Anyways, i would like to know if it would be possible to say, take Columns 1 and Column 2 and multiply the value of each row and post it to a Column 3 with each row in Column 3 reflecting the multiplied values of the previous 2 columns. Im sure i will wind up having to use some sort of SQL statement instead but thought id ask before I get tied up with that. thanks alot.
tibor
|