Hi guys, I know how to add rows to the MSFlexgrid. But how do I do it like it is done in Excel. Like if I have a row highlighted or right-click and say add new row a new row should be added at that position.
Please help.:wave:
Printable View
Hi guys, I know how to add rows to the MSFlexgrid. But how do I do it like it is done in Excel. Like if I have a row highlighted or right-click and say add new row a new row should be added at that position.
Please help.:wave:
I assume you've got to add the new row at the bottom and then move all data one row down. But probably you already thought of that. I really don't know if the msflexgrid has such an automatic capability.Quote:
Originally Posted by Nitesh
does anyone know of any grid in VB that will enable me to do what I want to.:(
Is there any special reason why you wouldn't do it the way I seggested? It's just a few lines of code.
ok i will give it a go now. will you please help me if I get stuck.;)
Hey Guys,
What about this. Would this be correct:
For adding a row:
where jobcard1 is the name of my MSFlexgrid:
for deleting a row:Code:Form2.JobCard1.AddItem "", Form2.JobCard1.Row
Alternatively I have this code for adding a new row and shifting the rest of the rows down from the one that is selected:Code:Form2.JobCard1.RemoveItem (Form2.JobCard1.Row)
Some expert opinions are needed please. I am confused as to which method I should use.Code:Dim oldRow As Long
Dim lngRow As Long
Dim lngCol As Long
Form2.JobCard1.Rows = Form2.JobCard1.Rows + 1
For lngRow = Form2.JobCard1.Rows - 2 To Form2.JobCard1.Row Step -1
For lngCol = 0 To Form2.JobCard1.Cols - 1
Form2.JobCard1.TextMatrix(lngRow + 1, lngCol) = Form2.JobCard1.TextMatrix(lngRow, lngCol)
If lngRow = Form2.JobCard1.Row Then
Form2.JobCard1.TextMatrix(lngRow, lngCol) = "" 'Make the current row empty
End If
Next
Next
I believe you still have to include the index in an MSFlexGrid, although I may be wrong:
Form2.JobCard1.AddItem "", 0, Form2.JobCard1.Row
And, of course, 'Form2.' isn't needed if the code is in Form2's code.
I'm not sitting right now in front of the computer where I have my VB environment. But just try it out and see if it works for you.Quote:
Originally Posted by Nitesh
The above syntax is correct and a new row is created before the current row.Quote:
Form2.JobCard1.AddItem "", Form2.JobCard1.Row
thanks alot everyone. That problem is sorted. Now, I have to get my head around the following. Any ideas would be greatly appreciated.
I have merged row 2 so that it looks like a heading called "Repair Work Required". Under this I have sub headings like date,start time and end time that the user would enter data for.
5 rows after that I have another heading called "Execute Repair Work Required" which has its own sub headings that will have values entered.
Say if I add a row under the first heading how can I determine which heading that row falls under and then save it accordingly to my database.
I need to capture a job card. All of the above are items of the job card. I have a table called job card which holds information like JobCardId and DateStarted. I have a table called JobCardItem which has the JobCardID as a foreign key etc.
But seeing as I have categories like "Repair Work Required" and "Execute Repair Work Required" and "Parts Purchased", how should I structure my tables. I would also need to record the number of rows for a certain Job Card wouldn't I. Do I make seperate tables for each category within the Job Card?
Hope I have been clear enough. Please help.