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




Add Columns To Data Grid At Runtime


Hello there, I'm using visual basic 6 and I'd like to know how to add columns to a datagrid at run time. Once I create this, I'd like for the user to enter info into the datagrid and insert that data into my database.

Thanks,




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Data Grid Columns ?
Yeah I want to increase the columns of Data Grid control using with ADODC but I couldn't find any property of it to do that. I have 6 fields in my table but it only shows 2 fields so what to do now ?

Need Help With Creating Dynamic Columns In Data Grid Please!!!
hi,
iam new to vb.net.iam working on a application where the user has the option to select the fields and datatype for the client table they want to build by checking the checkboxes for the data type and entering the field in the textbox.This information is saved in the table in MSaccess .I now would like to display this client table in the datagrid.i would have to get the fields from the table and make it the column headers in the data grid.
i have no idea how to achieve this. can someone help me with the code its very urgent please!!!!
thanks,

How To Swap Data Grid Columns At Run Time (Problem Solved - Thanks... Ian)
Please let me know if there is a way to swap grid columns at run time. If not, is there any other control in vb to do the work?

User should be able to drag a column and drop it to some other position, e.g.: if column 1 is dragged and dropped at column 4, columns 2, 3, 4 should get shifted to left.

I am using VB 6.0 with mySQL as the back end.

Please help me... This is urgent.

Thanks & regards,

Pradeepika.




Edited by - pradeepika on 7/1/2005 10:33:00 PM

How To Add Data To Flex Grid During Runtime?
guys,

would it be possible to load data to ms flex grid at runtime?

I am using visual basic 6 and Oracle 10g as my database... I acquired a class provided by oracle on how to extract data from Oracle DB...

I wanted to do a looping routine to load retrieve data to MS Flex Grid...

Please help..

tnx in advance..

Grid With Columns?
I am trying to find a control that i can use that would let me have column headers, like Item, price, description, etc.


then I want to be able to add rows to that... I can't seem to find one! anyone?

(Like this I guess: http://www.microregister.com/shareware/mrpos.jpg ... the orange is the headers)

Thanks

Grid With Columns?
I am trying to find a control that i can use that would let me have column headers, like Item, price, description, etc.


then I want to be able to add rows to that... I can't seem to find one! anyone?

(Like this I guess: http://www.microregister.com/shareware/mrpos.jpg ... the orange is the headers)

Thanks

Grid Columns
It's become crytical for me to have a grid in my app that's able to split columns, or in other words have columns with sub-columns. I've looked ad MSHFlexGrid's hierarchy-feature and found it quite usefull for another part of my app, but not for this.

What can I use to accomplish this. Maybe a datagrid? It looked like it could work, by I don't use data enviroments and it doesn't seem like the datagrid is for unbound use.

Thanks.

Procedure For Columns In Grid
Hi ,
I have 10 procedures that arranges the columns headers of the MSHFlexgrid depending on the current data within it.
the difference between them is the number of columns that need to be change

for example :

Public Sub Dial_Column_Headers_Type2()
With FrmAssign.MSHFlexGridEquipmentSearch
.ColWidth(7) = 0
.ColWidth(8) = 0
.ColWidth(9) = 0
s$ = "<Login Name |<Last Name |<First Name |<Dial No |<Phone No |<Destination |<Comment "
.FormatString = s$
.ColWidth(0) = 1000
.ColWidth(1) = 1000
.ColWidth(2) = 1000
.ColWidth(3) = 1400
.ColWidth(4) = 800
.ColWidth(5) = 1400
.ColWidth(6) = 1600
End With
End Sub


my question is how to build some general procedure for that

i started to write something but i don't know how to deal with the variable Columns

Public Sub Arrange_Columns_Headers(flexgrid As MSHFlexGrid, Headers_Order As String )
With flexgrid
s$ = Headers_Order
.
.
.
End Sub

Number Of Columns In Grid
what function or property would give me the number of columns in my DBGrid?

thanks
gary

Grid's Columns Color
Hello Folks.... i have a problem... i m using TDbgrid8.0 . i m setting color of column with doctor's availability . i have time starting 9:00am to 5:00pm. if doctor time is 9:00am to 12pm and 2pm to 5:00pm the color of tat doctor will show in those time slots... when i set the color of those cells then it will give color of all cells in all rows. can any body tell me wat i can do....

Sumarize Columns In A Grid
How can I do to sumarize or totalize values from columns, I need to accumulate a total, but this code does not do that. Any time I click a column the total desapers and does not accumulate nothing.

Private Sub DBGrid1_AfterColUpdate(ByVal ColIndex As Integer)
Dim var1 As Currency
Dim var2 As Currency

var1 = DBGrid1.Columns(3).Value
var2 = DBGrid1.Columns(4).Value
Text5.Text = var1 + var1
Text6.Text = var2 + var2
End Sub

Thank you in advance

Sizing Of Columns In A Grid
How do you have vb automatically size a msflexgrid to the longest field in the record extracted from the database?

does anyone know?

Sorting Columns In Grid
<html><div style='background-color:'><DIV></DIV>
<P>Hi Friends,</P>
<P>I would like to sort on any one of the columns simply by clicking on the column header in Sheridian DB Grid.</P>
<P>Can anyone please let me know,</P>
<P>Thanks,</P>
<P>VKT<BR><BR><BR><BR><BR><BR></P>
<DIV></DIV></div><br clear=all><hr>Talk to Karthikeyan. Watch his stunning feats. <a href="http://g.msn.com/8HMBENIN/2731??PS=">Download images.</a> </html>

Sorting Columns In Grid
Is there a grid that you can transfer columns from one place to another during run time and sort columns from ascendint to descending also during run time?

Automatically Resize Grid Columns?
Is it possibly to resize a MSHFlexGrid's columns according to how much data is in them?

[B]Flex Grid Columns At Run Time[/B]
Hi All,

Is it possible to specify the columns for flex grid at run time?
What i mean is....
I have a form which contains 2 command buttons and a flex grid control.
If command button 1 is pressed flex grid with 5 columns should be displayed.
If command button 2 is pressed flex grid with 6 colums should be displayed.

I want to do this without using 2 flex grid controls.
Is it Possible?
Please Help!

Janus Grid - Tooltips For Columns
How do u set individual tooltips in a janus grid for columns??? There is a tooltip property on the grid but this is for the whole grid. I am using version 1.6.

Thanks

Populating A DB Grid With Columns From 2 Different Tables
Hi There,

I have been trying to protype this for a few hours and do not seem to be getting anywhere,  so could someone please help point me in the right direction.

I have a DB table that has 2 columns in it - I only wish one of these columns to be displayed in the DB grid. I also want another column in the DB grid that contains a column from another DB table. I am OK with doing this, but my problem comes when I want to make the second DB grid column a drop down list, based upon the contents of a column from a second db table.

eg.

Column1                     column2
dbtbl1.machinename          dbtbl2.fault_reasons(dropdown)

Any pointers would be most welcome


Problem: Grid Columns? What's The Best Component??
I have this problem:

I have to show in a grid information of several products.

The product A has 3 columns
The product B has 8 columns
The product C has 6 columns.

This way, there are some columns that will be empty and this is bad to the user.

I have the option to use TreeView, List but i need some help.

Tks

Adding And Removing Columns In The Grid OCX VB6
I can use Add and Remove Item to add and remove rows in the Grid OCX but how do I add or remove columns. In an ideal world I would like to load a new Grid as a part of a control Array and dimension the number of columns and rows at run time as well as later add and remove columns?

Trying To Remove Columns From Vbaccelerator Grid..
z = vbalgrid1.Columns
'remove columns

For X = z To 1 Step -1
vbalgrid1.RemoveColumn vbalgrid1.ColumnKey(X)
Next

Returns 'subscript out of range'. This is in a grid with no rows and 12 columns.

Can anyone help?

Thanks!

Custom Color For Database Grid Row/columns?
Hi

I dont find any option to customise foregroud/background color for individual row/columns of DataBaseGrid-OLEDB ActiveX component.

Any help?

Letting Users Define Grid Columns?
Kind of a GUI question….


I have an application that has a list of orders, using a grid. The columns of the grid vary, that is, Order Number, Order Date, Order Status, etc.

I want to be able to let each user choose what columns are in their grid and their order.

I was thinking of something like a list of available fields on the left and a sample grid on the right. Users would grab a field on the list and drag it over to the grid and plop it down. Or maybe just hit a >> button to move the field over to the grid on the right. Then they can arrange the ordering and size on the grid.

Anyone have code or a sample of something like this?

Print Flex Grid (with Aligned Columns)
The following prints a flex grid, but the columns are not aligned. What is the best way to have aligned columns. First column is 12 characters, second column 20 characters, third 15 characters.

Thanks!!


VB Code:
Private Sub cmdPrintIt_Click()     Dim i As Integer    On Error GoTo ErrHandler    Printer.FontBold = False    Printer.FontItalic = False    Printer.FontName = "Arial"    Printer.FontSize = 12         Printer.Print ""    For i = 0 To flxLastWorked.Rows - 1        Printer.Print flxLastWorked.TextMatrix(i, 0) _        & "  " & flxLastWorked.TextMatrix(i, 1) _        & "  " & flxLastWorked.TextMatrix(i, 2)    Next i         Printer.EndDoc Exit SubErrHandler:    Select Case Err.Number        Case 484   'No Printer found..            MsgBox "No Printer found.", vbExclamation + vbOKOnly, "Error"        Case Else  'Another Error            MsgBox "Error Number: " & Err.Number & " Description: " & Err.Description    End SelectEnd Sub

FlexGrid Columns Will Not Resize With Grid Or Form
HI,

I would like to know if the columns in a FlexGrid should follow the Grid as its sized up or down?

I can resize both the form and the FlexGrid but the columns never change their widths. It appears that I can get the height to change which may have more to do with a dynamically reduced font size as the form/FlexGrid shrinks.

The FlexGrid is dynamically created in a Form_Activate subroutine.

Please advise.
Thanks

Hiding Rows/columns In Flex Grid
We hide rows and columns in flex grids by setting the COLWIDTH or ROWHEIGHT to 0.

This has some odd display behavior. You can almost see the "hidden" rows - they make the "dividing line" between the rows less dark.

Has anyone else used a different technique for hiding rows or columns?

Text Over Multiple Columns In Flex Grid
is it possible to have a heading centered over multiple columns of a MS Flexgrid?

eg

Code:

| this is a heading |
| 2 | 4 | 5 |
| 3 | 5 | 5 |

Flex Grid Sizing And Naming Columns
I've tried resizing the flex grid with some of the code that's located in these posts but was unable to get it to work.
I've got a flex grid being loaded with a Recordset and I want the columns to automatically fit the longest text string,
no more no less....also is there a way to rename the columns at the top of the flexgrid without having to use individual labels,
so in other words,direct caption editing of the flexgrid caption per column. It automatically defaults to the Recordset
caption. I can turn it on or off or rename a whole section, but not individual columns?

Thanks all....and always.....Dreamon!!

Truegrid V7 Summing Two Columns On Bound Grid????? PLZ HELP!!!
Hi All,

I'm using Truegrid V7 and I am showing stock figures using a bound ado control. That bit is fine but I also want to have one of the columns as a sum of the other two. Does anyone have any ideas as I am well and truely stuck!

Thanx very much inadvance,

Jiggy!

Adding Columns At Runtime
I am trying to write VB code to add fields to some tables on an existing Access database. I tried simply executing an SQL ALTER TABLE statement:

Code:
ALTER TABLE Residents ADD Address2 VARCHAR(50)
This code does add the new column to the table, but with two problems: Allow Zero Length is turned off, and the new field goes to the very end of the database.

I need the new field to allow zero-length values, and I would like it to be placed between two existing fields. Are either of these possible with an ALTER TABLE statement, or is there another way to alter the database in code which would support these requests?

Adding Of Columns At Runtime.
hi all , are there any sql statements or vbcodes for adding additional columns to a table in sql server at runtime?

thanks

Printing Word Warpped Flexi Grid Columns
I know how to print flexi grid data, but I am having problems if it is warped. After reading previous posts I wrote my own code to print the rows and columns. But it does not print warped columns properly. Example....

Grid Data:
-------------------------------------------------------------------------------
This text | Column 2 | Column 3 |
will Warp | | |
-------------------------------------------------------------------------------

I want printing to be.....

-------------------------------------------------------------------------------

This text Column 2 Column 3
will Warp

-------------------------------------------------------------------------------

But I get.....

-------------------------------------------------------------------------------

This text will Warp Column 2 Column 3

-------------------------------------------------------------------------------


My Code:


Code:
Dim Rows As Integer
Dim Cols As Integer
Dim X() As Integer
Dim Y() As Integer
Dim LastX As Integer
Dim LastY As Integer
Dim MaxWidth() As Integer
Dim MaxHeight() As Integer

Private Sub printGrid()
Dim tempWidth As Long
Dim Pages As Integer
Dim Copy As Integer
Dim pCnt As Integer

Dim Copies() As Integer

Printer.Font = grdReport.CellFontName
Printer.FontSize = grdReport.CellFontSize

With grdReport
ReDim X(.Cols)
ReDim Y(.Rows)
ReDim MaxWidth(.Cols)
ReDim MaxHeight(.Rows)

X(1) = PD.LBorder
Y(1) = PD.TBorder

For Rows = 1 To (.Rows - 1)
For Cols = 1 To (.Cols - 1)
If CInt(Printer.TextWidth(grdReport.TextMatrix(Rows, Cols))) > MaxWidth(Cols) Then MaxWidth(Cols) = CInt(Printer.TextWidth(grdReport.TextMatrix(Rows, Cols)))
If CInt(Printer.TextHeight(grdReport.TextMatrix(Rows, Cols))) > MaxHeight(Rows) Then MaxHeight(Rows) = CInt(Printer.TextHeight(grdReport.TextMatrix(Rows, Cols)))
Next Cols
Next Rows

For Cnt = 1 To (grdReport.Cols - 1)
If (tempWidth + (MaxWidth(Cnt) + PD.CellWSpacing)) > (Printer.ScaleWidth - PD.LBorder - PD.RBorder) Then
tempWidth = (MaxWidth(Cnt) + PD.CellWSpacing)
Pages = Pages + 1
Else
tempWidth = tempWidth + (MaxWidth(Cnt) + PD.CellWSpacing)
End If

Next Cnt

ReDim Copies(Pages + 1)

Pages = 0
tempWidth = 0

For Cnt = 1 To (grdReport.Cols - 1)
If (tempWidth + (MaxWidth(Cnt) + PD.CellWSpacing)) > (Printer.ScaleWidth - PD.LBorder - PD.RBorder) Then
tempWidth = (MaxWidth(Cnt) + PD.CellWSpacing)
Pages = Pages + 1
Copies(Pages) = (Cnt - Copies(Pages - 1))
Else
tempWidth = tempWidth + (MaxWidth(Cnt) + PD.CellWSpacing)
End If
Next Cnt

Copy = 0
For pCnt = 1 To Pages
Copy = Copy + Copies(pCnt)
Next pCnt

Copies(Pages + 1) = (grdReport.Cols - Copy - 1)


On Error GoTo Err

For Cnt = 0 To Pages
For Rows = 1 To (.Rows - 1)
For Cols = 1 To (Copies(Cnt + 1))

Copy = 0
For pCnt = 1 To Cnt
Copy = Copy + Copies(pCnt)
Next pCnt

If X(Cols + Copy) = 0 And (Cols + Copy) <> 0 Then
X(Cols + Copy) = LastX + PD.CellWSpacing + MaxWidth((Cols - 1) + Copy)
End If

Printer.CurrentX = X(Cols + Copy)
Printer.CurrentY = Y(Rows)
LastX = Printer.CurrentX
LastY = Printer.CurrentY

Printer.Print grdReport.TextMatrix(Rows, (Cols + Copy))
Next Cols
Y(Rows + 1) = Y(Rows) + MaxHeight(Rows) + PD.CellHSpacing
If (Y(Rows + 1) + MaxHeight(Rows)) > Printer.ScaleHeight Then
Y(Rows + 1) = PD.TBorder
Printer.NewPage
End If
Next Rows
Debug.Assert False
If Cnt = Pages Then Exit For
X(Cols + Copy) = PD.LBorder
Y(0) = PD.TBorder
LastX = 0
LastY = 0
Printer.NewPage
Next Cnt

End With
Printer.EndDoc
Exit Sub
Err:
If Err.Number = 482 Then MsgBox "There was a Printer Error in printing the Data", vbOKOnly + vbExclamation, "Printer Error"
End Sub


-------------------------------------------------------------------------------

There might be some flaws in the code due to my experience level. (I know 1 place). Any way I would appreciate if you help me.
The MSH Flexi Grid Control is name 'grdReport' and Command Button as 'cmdReport'

MS Flex Grid - Displaying ???? In Text Columns On Win98
All,

I developed an app on Win2000 using a MS Flex Grid.
The grid does not work properly on Win98 machines.

Is there are quick fix for this?

thanks in advance.
Scott

Scott Keith
Software Engineer
UPS Freight Services
972-304-3171

Can Drop Down In MSFlex Grid 7.0 Have Two Columns With Fixed Header
I want to have Fixed Header on combo box of VS Flex Grid 7.0. I have done the work for having a combo box with two columns in a cell on VS Flex Grid. But I am still unable have two Fixed Header for those combo box columns. Please help me in this regard.

Defining Columns To Select At Runtime
Hello,

I am trying to write an update statement that will select a particular column during execution time. The problem is that the value of a local variable will determine the name of the column, so if the variable's value is '01' , then Col01 is selected from a table. Here's some code I have tried:

Update Table1
Set tmptblcol = TempTable2.Col+@colname

or

Update Table1
Set tmptblcol = TempTable2.[Col+@colname]

or

Update Table1
If @colname = '01'
Set tmptblcol = TempTable2.Col01
Else if @colname = '01'
Set tmptblcol = TempTable2.Col02

So far, T-SQL one cannot define column names on the fly...

Any help is appreciated.

Thanks.

Displaying Data In A (data Grid / Flex Grid)
hi i would like to know how to connect to a Access database and display all records in a flex grid in VB

also i would like to know how to achive the above task from a SQL dadabse using ADO.. in VB

Plz help me...


Shabbeer

How Do I Add Rows And Columns To A Datagrid Or An MSflexgrid At Runtime?
I want to add rows and columns to a datagrid or an Msflexgrid at runtime. Please let me know as to how should I go about it.

Thank You.

Check For Duplicate Columns While Adding At Runtime
hi

I'm using vb6 and sql.

I'm was trying to add columns to a datagrid at runtime usind Ado. Actually I have been successful, except that I dont know how to check if a column being entered by the user already exists.Hence an error occurs if a col already exists.

Does any1 hav a soln????

Here is the code I'm using:

Private Sub Command1_Click()
Dim strSql4 As String
Dim res As String
res = InputBox("Enter Property Name", "Add Property")

strSql4 = "alter table rm_analysis" & _
" add " & res & " varchar (30)"
rsRM_ANALYSIS.Close
rsRM_ANALYSIS.Open strSql4, con, adOpenDynamic, adLockOptimistic
Adodc1.Recordset.Update
Adodc1.Recordset.Requery
Adodc1.Refresh
DataGrid1.Refresh

End Sub

MSHFlexGrid 2 Things I Want To Edit Data In Grid And 2 I Want To Re Populate Grid
  Ok First I want to Edit the Data in the Grid... Note this is partially setup.

  I have it so that I can Edit each cell however, I havent the slightest idea of how to go about saving the edited row after its edited.

  Ok, I have 3 option buttons.... I want to select an option button and it re populate the grid with a new MDB file. I figure I will need to Close the current open MDB so I can repopulate the grid... but How to accomplish this is the question.

  

About Data Grid Flex Grid And Other Family
1. what is the best control with the latest updatable fetures in this family
2. right know (until someone tell me that thire is a better control) i am using data grid, now i want to send data during my program to the data grid and i want that the data grid will show this data, now i dont want to send this data to the data base but directly to the grid, is that possible if yes how does it done .
thanks you all


janiv

Diffrence Between Flex Grid And Data Grid????
HI,

I want to know what is the difference between Ms flex grid and MS data grid?

pls tell me

thank u

sowmya s

Selected Row In A Data Grid Or A Msh Flex Grid
The user has to select a row from a data grid of a mshflex grid. The information seen in the data grid or the msh flex grid depends on a selection in an other combo box, this works fine. Now the goal is to copy one single column of the selected row in the data grid or msh flex grid to a ordinary listbox.
I've tried all methods but nothing works!

PLEASE HELP ME! I'M SO BLOODY DESPERATED!

S-Grid Runtime Error
I was browsing the excellent VBAccelarator site, and found a grid named S-Grid. The demo looks very promising, but when I try it in my application, it gives the error "Runtime error '0'".

The strange thing is that when I run the demo's group file (.vbg) everything works OK, but when I try the accompanied .exe file, it gives the same error, along with the message that it couldn't load vbalgrid from 'vbalgrid.ocx' and that my ocx may be outdated.

I've referenced the needed 'SsubTmr.dll', and added all components needed. I also registered all ocx files and the dll file.

Does anyone have some experience with this grid and can explain to my how to solve this error?

Dave.

Runtime Error 444 While Adding A New Value In Grid
hi
when i try to add some new value in grid then during dataset refresh associated with that grid, it gives runtime error 444.
Can anybody help?
Thanks
sanjeev

Filling Records In Grid At Runtime
Hi Everybuddy

Iam want to use a grid(flexgrid / dbgrid) in my form
Iam fetching records at runtime using ADODB like:
Dim cn as...
connection string=...
cn.open conn...
dim rs as new adodb.recordset
str="select ...a query"
rs.open str , cn , adlock....
Now I want to fill my grid with rs
ILL be really happy if someone cud help
Thanku
Pallavi

Help With MSFlex Grid Or Data Grid
Can anyone direct me to a user-friendly discussion on either MSFlex Grid and data grid controls. I’m trying to mimic the appearance of an excel spreadsheet in a VB form and was told one of those grids would do it. However I have never used either before and cannot find any posts/lessons/pages on MSDN that clearly explain how to do what I want.

Which, in case it helps is this: Currently have an excel spreadsheet with dates across the column headings and room numbers for row headings, cells are filled with patients names for each room and the respective dates they are staying (which is taken from our db).
This is mainly used by our volunteers to quickly see if beds are available for additional patients, however, as the info is entered once in the database and again in the spreadsheet there have been numerous discrepancies. As many of the volunteers are older we don’t want to change the appearance too much.
If the info is in the db I figured there must be some way to mimic the spreadsheet in VB, which I’ve been informed is the aforementioned grids. But I have no idea how to set this up and cannot find a clear explanation.
ANY assistance is greatly appreciated on this one!
Cheers

Data Grid & Flex Grid
I want a Data/Flex Grid to design the Sales Invoice Form; where a Combo Box(es) should be attached to Part ID: and Item/Part Name, the Editing should be done in the Grid itself...
Grid Cols.
SL. Part ID. Part Name Qty. Rate Disc. Amount
(Combo (Combo to
List IDs) List Part Name(s))

-> Edit/Data Entry should be done in the Grid...

Copy Grid Data From One Grid To Another.
I need some help here. I have two grid Parent and child. I have a column in Parent grid called total Qty. What I want to do is on the form load event and Parent grid click event, i want to populate the child grid from the values of parent grid. I need to keep in mind totlal QTY, and divide that Qty by a standard number and show multiple rows in child.
So for one parent I will have coulple of child.
Here is example.
Parent has Total Qty = 60
My standard# = 12
So Total Child Rows = 60/12 = 5 rows in child grid

I need to copy same data 5 times with qty Row like 12,12,12,12,12..
Can someone please help.

ADO With Flex Grid Or Data Grid
hai friends,

   i find the solution to connect the Excel file using ADO in the website


http://support.microsoft.com/default.aspx?scid=kb;EN-US;257819#Connect

when i include a flex grid or data grid & changed the record source of .xls file, its not displaying.

where is the problem

rectify this

Geetha

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