Re: Which grid should I use
First blush would be the data grid. I use them in a few places, but I don't like them. I prefer the flexgrid. I have used the floating text box without any problem. However, the grid where I use that is a "fill in the data" type of grid, not 'change it as you go'. I just find I have more control over what is happening if I use the flex grid. I'm sure there will be many who disagree.
Re: Which grid should I use
Moved to General Developer.
Actually, you can edit the flexgrid with some code.
Based on what I read, you are pretty much restricting the question to the Grids available with VB, or do you want to expand the question into third party grid controls?
Re: Which grid should I use
I'm only interested in the basic vb grids.
you can edit the flexgrid? could you point me at an example/tutorial? ...and thanks, you may be about to resove my longest standing vb gripe.
Re: Which grid should I use
The scroll issue you mention is the only one that we've encountered with floating a textbox or combobox on a flex grid cell...
And it can be dealt with by restricting the scroll in the MSFLEXGRID scroll event - which is what we do. Basically you cannot scroll if the textbox would be cause to disappear off the grid.
Once you have that logic for you program, it's set forever...
Re: Which grid should I use
I use the flexgrid myself. If you search for floating textbox, you will find many links. Here is one of them for you, with the method that I use.
http://www.vbforums.com/showthread.p...oating+textbox
Re: Which grid should I use
MSFlexgrid
VB Code:
Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
With MSFlexGrid1
Select Case KeyAscii
Case 8: 'IF KEY IS BACKSPACE THEN
If .Text <> "" Then .Text = _
Left$(.Text, (Len(.Text) - 1))
Case 13: 'IF KEY IS ENTER THEN
Select Case .Col
Case Is < (.Cols - 1):
SendKeys "{right}"
Case (.Cols - 1):
If (.Row + 1) = .Rows Then
.Rows = .Rows + 1
End If
SendKeys "{home}" + "{down}"
End Select
Case Else
.Text = .Text + Chr$(KeyAscii)
'write your own keyascii Validations under
'commented lines
Select Case .Col
Case 0, 1, 2:
'if (your condition(s)) then
'accept only charectors
'Else
' keyascii=0
'End If
Case Else:
End Select
End Select
End With
End Sub
MSHFlexgrid
VB Code:
Private Sub MSHFlexGrid1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case vbKeyReturn, vbKeyTab
'move to next cell.
With MSHFlexGrid1
If .Col + 1 <= .Cols - 1 Then
.Col = .Col + 1
Else
If .Row + 1 <= .Rows - 1 Then
.Row = .Row + 1
.Col = 0
Else
.Row = 1
.Col = 0
End If
End If
End With
Case vbKeyBack
With MSHFlexGrid1
'remove the last character, if any.
If Len(.Text) Then
.Text = Left(.Text, Len(.Text) - 1)
End If
End With
Case Is < 32
Case Else
With MSHFlexGrid1
.Text = .Text & Chr(KeyAscii)
End With
End Select
End Sub
Re: Which grid should I use
You also might want to check out this little tidbit by Martin Liss in the CodeBank section. :thumb:
Re: Which grid should I use
Hack - I've seen the "catch keypress" and put into current cell trick on the forum here before...
But I'm sure my customers would not like the non-windows feel of that. COPY/PASTE - select/DELETE - using the arrows to move back into the text and correct or delete a typo.
Have you used this before? What was the user reaction?
Re: Which grid should I use
Wow, you go away for a couple of days and suddenly there's LOADS of info. Thanks guys.
Unfortunately I always seem to need to put too much info in a grid to get away with disabling the scroll bars but catching the keypress looks like it'll do everything I want.
I'm going to have a play with it for a few days and try to break it. If there's anything I can't do using this technique I'll let you know.
Thx again
Re: Which grid should I use
Quote:
Originally Posted by szlamany
Hack - I've seen the "catch keypress" and put into current cell trick on the forum here before...
But I'm sure my customers would not like the non-windows feel of that. COPY/PASTE - select/DELETE - using the arrows to move back into the text and correct or delete a typo.
Have you used this before? What was the user reaction?
In our commerical apps we use a third party grid that has far more flexibility than any grid that ships with VB. What I posted was some old code that I've used in corporate applications.
You are right about your observations. I wouldn't be using that in commerical applications, but then, I can't imagine anyone writing a commerical application that would use a VB grid.
Re: Which grid should I use
Quote:
Originally Posted by Hack
...but then, I can't imagine anyone writing a commerical application that would use a VB grid.
We use the MSFlexGrid :blush:
It does work for us - not sure what functionality other grids would offer that my customers would need...
Although, now that you mention it, I don't like the MSFlexGrid sort capabilities or how much effort you have to go through to insure that a row is visible, the strange artifacts that appear on the grid when you make rows disappear...
Re: Which grid should I use
Quote:
Originally Posted by szlamany
We use the MSFlexGrid :blush:
It does work for us - not sure what functionality other grids would offer that my customers would need...
Although, now that you mention it, I don't like the MSFlexGrid sort capabilities or how much effort you have to go through to insure that a row is visible, the strange artifacts that appear on the grid when you make rows disappear...
Look into the Grid control made by Infragistics (formerly Sheridan). It is way cool, and it is pretty easy to use programmatically and provides all sorts of delightful features that customer really like. As a developer, I couldn't tell what the thing costs or what a multi-developer license is, but we use that in all of our applications where a grid would be used.
(I was going to make some smart aleck remark about the commerical application of the MSFlexgrid, but then I thought - hey, you like szlamany, dont' bust his chops.)