|
-
July 22nd, 1999, 09:45 AM
#1
Listview
I want to change the column header of a ListView. I need to have two lines. The first is the column header and in the second line for each column i need a text box or combo box that goes togeher with the column header. Is any one has any idea of how to start to doing this. I need only instruction for starting this...
-
July 23rd, 1999, 12:57 AM
#2
Re: Listview
Go for MS FlexGrid.
It allows you to have multiple-rowed Column headers - what he calls as Fixed Columns.
You case is different. You may have to look at how to position Text boxes and Combo boxes in FlexGrid's Cells, for your requirement.
You can do this with Listview also but goes into subclassing etc, which is difficult.
-
July 23rd, 1999, 03:14 AM
#3
Re: Listview
There's an article at http://www.codeguru.com/vb/articles/1749.shtml that shows how to create an 'editable' MSFlexGrid - it would make a good starting point.
Chris Eastwood
CodeGuru - the website for developers
http://www.codeguru.com/vb
-
July 23rd, 1999, 03:29 AM
#4
Re: Listview
IMHO there is a much better implementation in the VB programmer's guide for VB 6.
Check out section "Editing Cells in a Hierarchical FlexGrid Spreadsheet".
Still, all those approaches suck. Did you ever click on the scrollbar of the grid, when the textbox was active?
Or change the font? or....
IMHO, if you need an editable grid, buy one or use the DB grid in unbound mode.
-
July 23rd, 1999, 04:04 AM
#5
Re: Listview
Hi Lothar
I've had to create a grid control at work that's based on the MSFlexGrid, none of the third party controls out there had what we needed at the time - it had to be editable with different type of controls (combo, textbox, usercontrols etc), it also had to support 'hidden' columns, drag&drop between/within grids, and multiple selection of individual rows (which you can't do with the FlexGrid, so I had to rewrite all the highlighting!) - the handling of focus for hiding the usercontrol is a nightmare but I managed to get around it in the end. Even resizing a column in the FlexGrid is difficult to detect (although you can fudge it with subclassing).
Chris Eastwood
CodeGuru - the website for developers
http://www.codeguru.com/vb
-
July 23rd, 1999, 04:05 AM
#6
Re: Listview
Ofcourse you will have to handle the scroll events when the Edit box is ON. I have done it for my prev. project. It seems to work decently fine.
Like, when the data is being edited, say date field, the user suddenly scrolls the s-bar, and i validate the text box input. If the validation fails (!), i have to set the scroll position back correclty and set back the focus to text box and all that.
True. It is not simple & staright forward with FlexGrid.
But doing the editable DB grid with Combobox Or listbox is no joke either!. Only for text box case, it is easy
-
July 23rd, 1999, 04:13 AM
#7
Re: Listview
that sounds really interesting.
Where did you publish that code?
Ok, just kidding :-)
(I wouldn't publish it either, I'd rather sell it)
-
July 23rd, 1999, 04:36 AM
#8
Re: Listview
;-)
It's a very cool control - it's being used in production app's at the moment. I'd love to publish the code on the net but it's (technically) owned by my employers, although as I'm looking for a new job - who knows!
Chris Eastwood
CodeGuru - the website for developers
http://www.codeguru.com/vb
-
July 23rd, 1999, 04:44 AM
#9
Re: Listview
OK. You want to give me some money.. please do:-)
I will show you a piece of that code. Stripping unnecessary code from that project was not easy.
I hope this give the idea:
private Sub grdDataEntry_Scroll()
If ModeNowEditing then
If AcceptEditVals(true) = false then
Beep
With grdDataEntry
.Row = m_EditStruct.iCellid_row
.Col = m_EditStruct.iCellid_col
.LeftCol = m_EditStruct.iLeftColumn
End With
End If
End If
End Sub
The bold & itelised stuff do the trick of restoring the scroll bar back to its place!!
Obviously, at the start of editing you have to save the 3 values. Also my grid had fixed rows and hence no VScroll. Otherwise you might have to store that value also, in order to get back properly
-
July 23rd, 1999, 04:48 AM
#10
Re: Listview
Hi Lother,
Sorry i got confused in the "Flat Threaded Mode".
I didn't see properly that your money offer was for Chris's comment :-) LOL**
-
July 23rd, 1999, 05:16 AM
#11
Re: Listview
never mind, just publish your bank account and I send you the 2 cents :-)
no, just kidding.
What I was trying to say is, that it's just too much effort to implement everything to make your editable grid a truly working grid.
That's my personal opinion.
-
July 25th, 1999, 02:18 AM
#12
Re: Listview
Hi Chris,
I have tried to use the MSFlesGrid for my needs - but with no success. I am really do not what to do. I don't need to edit a cell in the table. My list is not editable. The only thing that the user can change is the column header.
The column header should have 1 fix row for the header and the second row with edit box or combo box. The second line is for filtering the column (the user will type a word in a cell in the second row and the column will be filtered).
The user can change the order of the columns header (both lines) and can change the size of each cell.
When the user scroll the two lines columns will remain.
I know that i need to do it by my own and i am begining to learn VB just now.
So i will apprciate any help on this !!!... Thank you.
Can you tell me how you did the multiple selection, hidden columns...
Thanks.
-
July 25th, 1999, 02:39 AM
#13
Re: Listview
Thanks. Do you know a good article/source for subclassing...
Sigal
-
July 26th, 1999, 12:32 AM
#14
Re: Listview
Hi,
If you dont have dynamic editing , i.e any cell, it is even more easy, is int it?
just put textbox or Combobox, Statically, in all the cells of 2nd row, i mean on-top-of all cells on 2nd row.
Make the .FixedRows = 2, so that thy will remain even if user scrolls.
Try this code. It works:-)
Take a form. Put a MSFlexGrid. Put a check box.
Put 2 text boxes and 1 combo box. All default names.
Cut and paste this code.
private Sub Check1_Click()
Debug.Assert me.ScaleMode = vbTwips ' otherwise positions will get messed up
If Check1.Value = 1 then
With MSFlexGrid1
.Col = 1: .Row = 1 ' set the curnt cell
Text1.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth, .CellHeight
.Col = 2: .Row = 1 ' set the curnt cell
Combo1.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth ', .CellHeight
.Col = 3: .Row = 1 ' set the curnt cell
Text2.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth, .CellHeight
End With
else
Text1.Move Text1.Left, MSFlexGrid1.Top - Text1.Height
Combo1.Move Combo1.Left, MSFlexGrid1.Top - Text1.Height
Text2.Move Text2.Left, MSFlexGrid1.Top - Text1.Height
End If
End Sub
private Sub Form_Load()
MSFlexGrid1.Rows = 20
MsFlexGrid1.FixedRows = 2
Check1.Caption = "Move edit controls on to 2nd column"
End Sub
As you check & uncheck the check box, you will see that the controls jump up & down.
Scroll also works properly. Make .Rows more if required, to test.
This is a little rough logic. You may have to fine tune it: Like when the user drags the cells you have to adjust the positions. This logic in its present form works, if the columns are dragged when the controls are outside, and positioned back by Check1 click
-
July 26th, 1999, 02:45 AM
#15
Re: Listview
Thank you very very much. It is really help me to start understanding the idea- but there is one problem with your code that i am tring to solve is that the MSFlexGrid appear on top of the text box (the text box is under the second row and not visible). Do you have a quick solution ?
Thank you for everything.!!
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
|