-
June 16th, 2005, 05:47 AM
#1
How to add a row of data in MSFlexgrid
Hi all
I am fetching data from ms access into MS flex grid using ADOs. Now i want to add some rows of data into Flexgrid. Also i want to save the same data into access table. How it is possible.
I can add empty row by using
MSFlexGrid1.AddItem "", MSFlexGrid1.RowSel
but i want add field data also
regards
-
June 17th, 2005, 04:18 AM
#2
Re: How to add a row of data in MSFlexgrid
Hai
I got one solution to add data at the end of Datagrid using input Box with following code
For lcol = 1 To lfieldcnt
sFieldname(lcol) = InputBox(vColName(lcol))
MSFlexGrid1.Col = MSFlexGrid1.Col + 1
MSFlexGrid1.Text = sFieldname(lcol)
Next lcol
but i want to add directly with out input box.
And also i want to save this into ms access database. where i am using ADO. how to add, i mean save it into access
regards
Ravi
-
June 17th, 2005, 04:53 AM
#3
Re: How to add a row of data in MSFlexgrid
I don't think the above code add the data at the end of the grid !!!
If you want to enter values into the grid , u can refer the "EnterCell" and "LeaveCell" events in MSDN.
As for saving the data, U can just read the data from the grid and save it into the database (also available in MSDN)
-
June 19th, 2005, 08:45 AM
#4
Re: How to add a row of data in MSFlexgrid
If you are not familiar with the search function in this forum you should try it - there is a drop down button at the top right called "Search this forum"
Click on this and key "MSFLEXGRID" into the search - you will be amazed at what you will find (normally a lot more than you specifically asked for) !!!
Have a look at posts on Msflexgrid
eg
Headings
http://www.codeguru.com/forum/showth...ght=msflexgrid
Adding Rows to a Grid - Changing Colour of a Cell
http://www.codeguru.com/forum/showth...ght=msflexgrid
Good hunting
-
June 22nd, 2005, 05:00 AM
#5
Re: How to add a row of data in MSFlexgrid
You can add a row in msflexgrid with this line
msflexgrid.additem field1 & vbtab & field2 & vbtab & field3,msflexgrid.rowsel
Hope this will work for you
-
June 22nd, 2005, 06:01 AM
#6
Re: How to add a row of data in MSFlexgrid
Yes I can add, But I want to add at the end of the flexgrid,if i click on flexgrid cell i have to add data there just like addind data in Excel sheet. is it possible, I can add data at the end of flex grid by using Inputbox
i am posting code here
Private Sub cmdAdd_Click()
Dim lfieldcnt As Long
Dim lcol As Long
Dim sFieldname() As String
Dim vColName As Variant
Dim lrecCount As Long
lfieldcnt = clsTree.FieldCount ' total field count
ReDim sFieldname(lfieldcnt)
vColName = clsTree.ColumnName ' name of the column
lrecCount = clsTree.RecordCount ' record count
MSFlexGrid1.Col = 0
MSFlexGrid1.Row = lrecCount
MSFlexGrid1.AddItem ""
lrecCount = lrecCount + 1
MSFlexGrid1.Row = lrecCount
For lcol = 1 To lfieldcnt
sFieldname(lcol) = InputBox(vColName(lcol))
'sFieldname(lcol) = MSFlexGrid1.TextArray(6)
MSFlexGrid1.Col = MSFlexGrid1.Col + 1
MSFlexGrid1.Text = sFieldname(lcol)
Next lcol
End Sub
any clues
thanks and rgards
Ravi
-
June 22nd, 2005, 06:17 AM
#7
Re: How to add a row of data in MSFlexgrid
u can use a text box with the grid to enter the text in the cell..initially the text box will be invisible and in the grid's click event u can make it visible and bring the focus to the text box..
and also in the grid's entercell event write this code..
txtgrid.Top = grid.Top + grid.CellTop
txtgrid.Left = grid.Left + grid.CellLeft
txtgrid.Width = grid.CellWidth
txtgrid.Height = grid.CellHeight
If LTrim(RTrim(grid.Text)) <> "0" Then
txtgrid.Text = LTrim(grid.Text)
Else
txtgrid.Text = ""
End If
txtgrid.Visible = True
txtgrid.SetFocus
where gridtxt is the name of text box and viewgrid is the grid's name..
and in the grid's leave cell event write this..
grid.Text = Str(Val(txtgrid.Text)).
hope this vil help..
-
June 22nd, 2005, 06:23 AM
#8
Re: How to add a row of data in MSFlexgrid
Thankyou
I will try with that
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|