Hey everyone, I got a pretty simple question, but I know that there is probably very few here that has ever used S Grid. For anyone that doesnt know or has never used S Grid, you can download and read about it, at the authors website http://www.vbaccelerator.com/home/VB...id_2/index.asp.
So anyways, here is the question. What is the alternative for the MSFlexGrid's .col & .row for the S Grid? For some reason I cant figure it out and in all the examples in using S Grid that I have seen, they use CellText(row,col) and not using an array of columns and rows the way that I am use to for displaying text.
So, if anyone could answer my question, or has any suggestions, that would be great. Thank You!
With SGrid 'Actually is SGrid-2, but I call it Sgrid
.Redraw = False
.Clear
lRow = 3
lCol = 5
.CellTextAlign(lRow, lCol) = DT_CENTER
.CellText(lRow, lCol) = pubRs!SalesPerson 'Place data into visible cell text
.CellItemData(lRow, lCol) = pubRs!SalesPersonID 'Place data into Cell's ItemData
.Redraw = True
End With
Ok, thanx for the replys! After changing my code around for the use of SGrid, the form seems to load up ALOT faster =). I have one more question though, I was merging the columns using flexgrid, (well, kinda, I never figured out why it sometimes wasnt merging), but I heard that S Grid doesnt do that! Does anyone know away around this of makeing two cells share the same border??
Btw, what is the difference between S Grid and S Grid 2?
Would anyone be able to guide me through the sort procedure?? It seems a lot more complacated then the flexgrid. You have to use the SortObject and it I would appriciate it if someone could help me out. Thanx.
In the mean time, I am attaching the Help file.
It is a web page from their site, but I have tweaked it slightly, and it is in a format that allows you to view it off-line.
The Sort Object is told about which cols to sort eg 3 then 5 then 1
And whether they are Ascending or Descending.
And what type of sort to use (Numeric, String, etc)
You add each col to the sort object, and set those properties
This is an example -
'Example for VBForums question
Private Sub ConfigureGridSorting()
With SGrid.SortObject
.Clear
'I use an array to keep track of the Col numbers (Longs).
'EG the array may contain 3 5 1
' Meaning sort col 3 first, then 5, etc
' some where else, you should store whether the sort is Asceneding or Descending.
'The author's examples use some ColumnSort.... fields
' Those are only used for the pgm to store data.
' I chose to store that data in arrays, instead.
'I am not saying my approach is better.
For i = 1 To myUB
'We have to add to the collection
NewSortCol = .Count + 1 '<= NewSortCol this refers to index in the SortObject
'The first created above, will be 1. Then 2 if you have two sort columns.
WhichColtoSort = aSortCols(i) '<== This is telling it to point to say Col 3
' Next time through the loop, the above will tell it 5
.SortColumn(NewSortCol) = WhichColtoSort
If SomePlaceWhereYouStoreAscDesc = 1 Then
.SortOrder(NewSortCol) = 1 'Ascending
Else
.SortOrder(NewSortCol) = 2 'Descending
End If
'When I configure the Grid (create it via code)
' As I add the Columns, I also store the sort type.
' EG Sort as Numeric, or as String etc
'I store that in SGrid.ColumnSortType (it is only storage)
'The next line is reading that, and telling the Sort Object about it.
.SortType(NewSortCol) = SGrid.ColumnSortType(WhichColtoSort)
Next i
End With
Call SortTheGrid
End Sub
'ROB has made this a Sub, so that other actions can be taken as well.
Private Sub SortTheGrid()
'Exit Sub, if no Rows.
If SGrid.Rows <= 0 Then
Exit Sub '<== Exit
End If
'If Total line is showing, then remove it
With SGrid
If .RowItemData(.Rows) = -999999999 Then
.RemoveRow SGrid.Rows
End If
.Sort
End With
End Sub
There are only two areas in SGrid2 that I have not explored =
Grouping
Row-Text Column
I don't know if they can help your need.
'Wild other suggestions'
Switch off grid lines, or
Choose a color for grid lines, and make the backcolor of adjoining cells the same, so they appear to be one cell
Rob,
PS My previous post will be more legible if you copy into an editor, and restore the tabbing.
Originally Posted by epod69
I was merging the columns using flexgrid, (well, kinda, I never figured out why it sometimes wasnt merging), but I heard that S Grid doesnt do that! Does anyone know away around this of makeing two cells share the same border??
Ok, sorry for that late reply, I got the columns to sort!! I cant be too excited though because for some reason its not sorting how its suppose to..
Here is my code:
VB Code:
'##############################################
'############## ACTIVATE ######################
'##############################################
' align morning grid
With MorningGrid
If .Rows > 0 Then
With MorningGrid.SortObject
.Clear
.SortColumn(1) = 2
.SortColumn(2) = 3
.SortColumn(3) = 1
.SortOrder(1) = CCLOrderAscending
.SortOrder(2) = CCLOrderAscending
.SortOrder(3) = CCLOrderAscending
.SortType(1) = CCLSortNumeric
.SortType(2) = CCLSortString
.SortType(3) = CCLSortDateMinuteAccuracy
End With
.Sort
'// Debugging Purposes //
For i = 1 To .Rows
For ii = 1 To 3
.SelectedRow = i
.SelectedCol = ii
Debug.Print .CellText(i, ii)
Next ii
Next i
'// End of Debugging //
End If
End With
' align afternoon grid
With AfternoonGrid
If .Rows > 0 Then
With MorningGrid.SortObject
.Clear
.SortColumn(1) = 2
.SortColumn(2) = 3
.SortColumn(3) = 1
.SortOrder(1) = CCLOrderAscending
.SortOrder(2) = CCLOrderAscending
.SortOrder(3) = CCLOrderAscending
.SortType(1) = CCLSortNumeric
.SortType(2) = CCLSortString
.SortType(3) = CCLSortDateMinuteAccuracy
End With
.Sort
'// Debugging Purposes //
For i = 1 To .Rows
For ii = 1 To 3
.SelectedRow = i
.SelectedCol = ii
Debug.Print .CellText(i, ii)
Next ii
Next i
'// End of Debugging //
End If
End With
Here is my what comes up on the debug:
This is for the Morning Grid
09:00 AM Showing / 09.00 / Showing
09:15 AM Appointment / 09.15 / Appointment
10:50 AM Appointment / 10.50 / Appointment
This is for the Afternoon Grid
12:00 PM Appointment / 12.00 / Appointment
04:00 PM Showing / 16.00 / Showing
06:00 PM Open House / 18.00 / OpenHouse
01:30 PM Appointment / 13.30?? / Appointment
06:20 PM To-Do / 18.20 / ToDo
So as you can see, something isnt right when sorting the afternoon grid. I am using the same code for the other grid and the other one works just fine. So I am stuck AGain!!
Any Suggestions??
Are you using
With MorningGrid.SortObject
with the Afternoon grid, instead of
With AfternoonGrid.SortObject
I cannot tell which data is in which columns from the example data you are showing.
If the above does not fix your problem, you can prepare a subset of your pgm, and send it to me (and illustrate what you expect the data to look like after sorting)
Are you using
With MorningGrid.SortObject
with the Afternoon grid, instead of
With AfternoonGrid.SortObject
I cannot tell which data is in which columns from the example data you are showing.
If the above does not fix your problem, you can prepare a subset of your pgm, and send it to me (and illustrate what you expect the data to look like after sorting)
Rob
Umm...lol, im an idiot ^-^!! Thanx soo much for noticeing.
Now the only other thing I have to work on is getting two cells to merge, or make it seem as they are merged. I think I am going to have to use the group method... so if you have any other suggestions, that would be great!! Thanx!
You could switch off the vertical grid lines, and align text in two adjoing cells as Right and Left.
However I raise the question 'is it a clean solution' to be merging columns ?
The SGrid can be used for a variety of needs, and no doubt some of them may find merging useful.
But with structured data, surely not ?
If you are displaying data that is like a visible multi-dimensional array
(typical use of a grid with columns and Rows), why would you want to merge some of that ?
If it is a desire to show more data than is visible in the cell, you can solve that by having a ToolTip for each cell.
I have ToolTips om many of my cells, and in one particular column, all the cells have a multi-line ToolTip, that shows 4 dates connected with the Job
(Creation Date, Date it became a Firm Job. Date it was completed, optional Date it was cancelled, etc)
Hmmmm. I was actually going to post that, but wasn't sure about your methods.
When you merge cells in a flexgrid, it just prevents the replication of adjacent cells that have duplicate information. They are grouped, and the first cell print whille the cellls below or to the right are blank. Not sure if that is what you wanted or not.
Thanks for that.
Reading your post reminds me of what I studied, long ago, and never used.
So instead my mind invented it's own definition of merging.
Before i prattle on further, perhaps epod69 could clarify what he needs.
(In his post he says 'well kinda')
If it is as you describe, then I suppose he could switch off grid lines, and his code could detect when the data in the cell below is the same, and blank the text in that cell. It could be done, but I wouldn't recommend adding complexity for cosmetic reasons.
Hi, and sorry for the late reply. I couldnt for the life of me get my project loaded on my home computer, it kept getting me a run-time error 0. =( Its a royal pain at least for me trying to register the s grid and getting it working properatly because the author doesnt have vb6!! Well anyways, im back at my work computer and I decided it would be best to put part of my project up that I am working on so you can help me out at best.
When you run the project, a calandar loads up. Most of the events should be in the month February so select the month box and select February. Then double click on a bolded date and the events for that day will load up in a new form. For right now, all i did is highlight the adjacent cell when ever you click on a cell to make it seem as they are both the same cell...its probably not the best way of going around it, the way I am doing it, I dont see how it could work with the grid lines turned on. (There is one wierd little bug right now as well that when you are in the second form, and you click back and forth quickly between the two s-grids, then it will not highlight the adjacent cell..! )
So anyways, it would be soo great if anyone could go through the attached project and help me out. My main concern is to get a better way of merging the cells and then hopefully fix the main bug. If anyone even has a better way/suggestion for making it a better appearance, that would be great as well.
Thank you RobCrombie, Wokawidget, and dglienna for posting and helping me out so far!
dglienna: When you merge cells in a flexgrid, it just prevents the replication of adjacent cells that have duplicate information.
When you merge cells in flexgrid, you can then make the cells have multilines which is what I am trying to do with S Grid.
Had a quick look, but it was going to take me too long to try to work out what
the pgm was doing, and what you specifically needed.
You coudl -
- try adding comments to your code
- get rid of code excess white space and tabbing(too wide)
- Add little 'Tip' labels to your Forms, so that user (and I) can work out what
to do.
The 'Tip' Labels mouseMove event can show a multiline Label giving something
like context help.
The Form's Mousemove, can then hide the multiline Help.
If you do something along the lines of the above, and clarify your problem a bit
more, I will have another look.
I guess I should of added comments before I uploaded the project..I have some of my own personal comments but I guess that only helps me out. As for the excessive white spaces and tabbing, that is just my taste in how I like to program, it seems less cluttered to me...but I havent attended any schooling either so I wouldnt really no what the "right" way in programming code would be.
What is retarded if I think about it, I am going through all this trouble for "cosmetic reasons"..
And I dont know what I am doing wrong, but I cant get the S Grid 2 to work on my home computer. I am using the same vb6 EE and I have registered it and installed the vb5 run-times and all the steps that were on the site but I cant get it to work =(. So if anyone would like to help me out on that, I will upload the project again with more comments and "tips".
Thank you all for helping!!
Why the VB5 runtime ?
You should be careful to get the VB6 and other stuff related to SGrid-2, avoiding any of the SGrid (first version) stuff.
I am trying to get people to use the SGrid-2, and you will be frightening them away.
I don't usually use controls (though I use user controls ctl), and I just give my user an exe to run (practically every Windows computer, these days, has the VB6 runtime installed already).
When I decided to go with the SGrid-2, it would have been necessary for me to provide them with install versions of my pgm, which I don't like.
Instead I created a once only installer for them that places the SGrid-2 and the related SSubTmr6.dll onto their computer. And I still just give them my EXEs like I used to.
The attached contains only those controls, and makes no other changes to your system. I believe all you have to do is install the attached, and all of your install problems will be over.
IF i'M CORRECT, AND IT IS THAT SIMPLE, PLEASE POST BACK HERE AND ADVISE ALL THOSE THAT YOU FRIGHTENED OFF, THAT IT IS NOW A PIECE OF CAKE TO USE THE SGRID-2
Hey again, following up on my previous post, I am putting up my project again, this time, I put step by step comments explaining the best I can on what is going on through the code. I did the comments on the second form only because I dont need any help on the first form at all.. I also put a label on the bottom of the form explaining on what I want to do/need help on.
So, if anyone would be able to help me out, that would be awsome. If nobody has S-Grid 2, then download RobCrombie's attachment in the above post. As soon as I get home, I will download the S-Grid 2 download on my home computer. Im sure it will work just fine. I also think that if you have never used S Grid before and you try it now, you will never go back to MSFlexGrid again!! S Grid is accually very simple, and yet more advanced then FlexGrid.
So anyways, if you can, please download my attached project and hopefully post any suggestions that you might have about it. And if you dont have S Grid, then you will need to download the above post's attachment.
The way I add more data to my cells is to switch off the normal grid and I add exta vertical or horizontal columns or rows with a width or height of 1 and a backcolour of vbBlack.
I keep track of the extra columns and rows by using indexes. You can either use Collections or Dictionaries for these depending on your preference.
So that I know which data I have in a cell I use the RowItemData and ColItemData properties to hold the REAL row and column array information, just in case any edits I do to the grid have to be backtracked through to my source array.
I really love this grid. I wish it would load a tad quicker though. 20-30mSec a column is what I find. On a large grid this can be a pain. Apart from that it is just so flexible. I especially like being able to use two icons in each cell. And the sort and grouping is to die
David
Learn the Rules so that you know how to break them properly.
Dear all,
In S-Grid 2 whenever the user starts grouping on a column, I want to total on a selected column and put it on the grouped row
e.g. In outloook, if you are grouping on the From address, it has total on the number of mails or total size of the mails from the grouped from address
I tried to do it in mousedown event, problem if you do grouping on column it is not firing any event.
Thanks & regards
Karthikeyan R
Hey, and thanx everyone for the replies! I installed the setup for the S Grid controls on my home computer which was posted by Rob, and it ran smooth and effortless and works perfect! Thanx Rob for that.
Posted by David.Poundall
Epod.
The way I add more data to my cells is to switch off the normal grid and I add exta vertical or horizontal columns or rows with a width or height of 1 and a backcolour of vbBlack.
If I understand you correct David, surrounding the two cells with a lair of columns and rows would make a border appearance arround the two cells giving them an appearance as if they were one cell. If so, that sounds like an excellent idea! In fact, thats pretty much all I am looking for appearance wise. You have also stated that you wish the grids would run a tad quicker. This project that I am working on is a Real Estate program, and the part of the project that I have loaded up is a schedule, and a person can only have so many events (appointments) in a day. So I think in my particular situation, I dont really have to worry about the grids performence.
Posted by RobCrombie
Hi,
InitFlexGrids is slightly longer than 'War and Peace'
(I haven't finished reading 'War and Peace' yet)
What if you set the alignment of the upper cell (Time) to be bottom.
And possibly set the alignment of the lower cell to top.
That way they will look related, and visibly separate from other entries.
LOL, I havent read 'War and Peace' either, but I doubt the code is longer then the book. InitFlexGrids will be three times larger once I add all the links from the first form to it, I hope it doesnt effect the purformance..
I havent thought of setting the upper or lower alignment of the cells either, that also sounds like a great idea!
r_karthy, I havent tried the S Grids Grouping feature either...sorry
Anyways, when I work on my project again, I will put in to it all the suggestions and I am sure everything will work out great! I will keep this thread informed on the status of the project, I am sure it wont take long to finish it now, and if requested, I will attach the finished project.
Thanx everyone for their help and support!!!!
Last edited by epod69; Mar 10th, 2005 at 02:49 AM.
Ok, im back at work, and I got a nice black border around every two cells just like I wanted!
I have run into some more trouble though. =( When the user selects the border, it highlights it just like any other cell, which of course I dont want to happen, so what I did was when the user selects the "border" I have it select the previous cells that were selected before that. This part works fine, so when the user does select the border, it doesnt show any change and the the previous selected cell stays selected. Now, the problem is if you click on the border in the other grid before any other cells, then there is a problem because there was no last selected cell for that grid so the variable lsr (last selected row) becomes 0 and causes an error..
Here is my code:
VB Code:
' If the selected cell is a border (has a black background)...
If .CellBackColor(lRow, lCol) = vbBlack Then
' lsr means Last Selected Row and will return 0 if a grid loses
' focus and lsr is changed if any cell is clicked on besides the
' border, so, lsr = 0 when the first cell of a grid clicked is a
' border
If Not lsr = 0 Then
' all this basically does is select the previous cell that was
' selected
.SelectedCol = 2
.SelectedRow = lsr
Call MergeRows(MorningGrid, lsr)
Else
' tried to see if setting focus back to the other grid would
' stop the problem but what happens is either the cell stays
' highlighted, or the entire row is cleared (turns white)
' which is really wierd
AfternoonGrid.SetFocus
End If
Exit Sub
End If
So if anyone knows of a better solution about this, that would be great! Thanx everyone!!
I tend to place my True Row count - by that I mean the row of the array that I am representing in the grid - in the .RowItemData property (it takes longs). The rows that you are using as your grid border also have this property so I will typically place the row true row count of the previous cell in the .RowItemData property of the border row.
Then if someone clicks on any Row (border or otherwise) I get to my array data using
MyData=MyArray(.RowItemData(LRow),LCol)
Every one a winner
HTH
David
Learn the Rules so that you know how to break them properly.
Hi,
For anyone wishing to install the ImageList control, as well, I am attaching a better installer, that includes -
SGrid-2
the DLL (Subclassing and Timer assistant)
ImageList Control
Hey guys, sorry for the late reply but I have been in the hospital for a while because of ulsers....goes to show you how much stress programming can be sometime =( LOL. But anyways, the good news is I did get the s grids working good and I think I wont need anymore help with them! =) I did use the .RowItemData property, and it acually became very useful, thanx for that suggestion David.Poundall.
There is one strange thing that I am wondering about.. When I run the project on my home computer, the columns are spaced (width) just how I want them. When I run the project on the work computer, the columns' width's are shorter, which doesnt make any sense, I am running the same code on both computers.
What would greatly bother me is if I made an executible of the project, that the grids would size differently on some computers...
Well if anyone knows of what could be causing the column width problems, please reply back. Thank you everyone for helping me out! vbforums Rocks!!!
The screen resolution on my home computer is 1028 x 768 and is at 32 bit. The resolution on my work computer is 1280 x 1024 and is at 16 bit. So they are at different resolutions...
Your pgm should be able to run on higher resolutions.
What should happen is the whole Form's image should be smaller.
Thus smaller column width, and smaller text.
That shouldn't be a problem as all other pgms would be treated similarly.
If you are getting smaller columns, AND larger text (text no longer fits the same), that means someone has found the high resolution hard to read and has gone into the advanced button (on the dialog where you change resolution), and changed the DPI setting.
If that is the case, then change the DPI back to Normal, and stand in the corner for two hours.
Hey, would of never thought of it, but the work computer's DPI was accually set to large font so when I changed it back to normal, the columns got big again, so now it should be the same with my home computer. Thanx for the help RobCrombie!! It took a while to get use to the computer....but I didnt have to stand in the corner for two hours =).
I tried taking your suggestion you made earlier about have the cell text aligned, the top being aligned to the botttom and the bottom being aligned to the top to make it look more merged.
I tried doing this..:
Code:
MorningGrid.CellTextAlign(Mr, Mc) = DT_CENTER And DT_BOTTOM
MorningGrid.CellTextAlign(Mr, Mc) = DT_CENTER And DT_TOP
I cant get it to work at all, is there something I am doing wrong?
Btw, Mr and Mc are in an array and this is pretty much what it is in my code..:
For i = 1 to 2
Mr = i
Mc = 2
Next i
Last edited by epod69; Mar 23rd, 2005 at 01:20 PM.
PS
Whilst searchiing for why that was necessary, I came across this
(Which might mean something to people that have used this API call) -
# CellTextAlign - Gets/sets the alignment and formatting properties used to draw cell text. The format used is the same as that used by the GDI API call DrawText and hence allows you to specify horizontal and vertical alignment as well as whether the text is single line or wrapped and/or whether the text is truncated.
And also noticed these, which may come in handy, one day -
# EvaluateTextHeight - Determines the ideal height required to display all the cell's text in a cell. This property is only of any use if the Cell's CellTextAlign property allows multiple lines.
# EvaluateTextWidth Determines the ideal width required to fully display text in a cell.
This looks like interesting thread.
I have a problem with editing data in SGrid 2. I'm connecting to SQL Server 2000. When user clicks on a row in SGrid 2, set of controls(datepickers, text and comboboxes) is filled with data from that row.
Data is edited in those controls and everything works fine if I dont drag column for grouping. If data is grouped by any column, record is edited and saved into database correctly, but it is not displayed in the grid until I restart whole program.
I also noticed that clicking on row group header displays "missing" record in controls. When I return to grid view without grouping, "missing" record is still missing, whole bunch of blank rows is added to the top of the grid and last record is duplicated at the bottom.
Does anyone have idea of what I'm doing wrong?
Here is the procedure that fills SGrid:
Why the VB5 runtime ?
You should be careful to get the VB6 and other stuff related to SGrid-2, avoiding any of the SGrid (first version) stuff.
I am trying to get people to use the SGrid-2, and you will be frightening them away.
I don't usually use controls (though I use user controls ctl), and I just give my user an exe to run (practically every Windows computer, these days, has the VB6 runtime installed already).
When I decided to go with the SGrid-2, it would have been necessary for me to provide them with install versions of my pgm, which I don't like.
Instead I created a once only installer for them that places the SGrid-2 and the related SSubTmr6.dll onto their computer. And I still just give them my EXEs like I used to.
The attached contains only those controls, and makes no other changes to your system. I believe all you have to do is install the attached, and all of your install problems will be over.
IF i'M CORRECT, AND IT IS THAT SIMPLE, PLEASE POST BACK HERE AND ADVISE ALL THOSE THAT YOU FRIGHTENED OFF, THAT IT IS NOW A PIECE OF CAKE TO USE THE SGRID-2
Rob
Hi, Why I can't download attached files from this post(#19)? Tanks.
Last edited by It.Behrooz; Dec 29th, 2021 at 07:14 AM.
If you're talking about the attachments to post #19 or #29, by the names of the attachments, they almost certainly had executable code in them, and that's not allowed on these forums. It's a terribly old thread, but you might try PMing the posters and see if they'll re-post with only the source code.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
If you're talking about the attachments to post #19 or #29, by the names of the attachments, they almost certainly had executable code in them, and that's not allowed on these forums. It's a terribly old thread, but you might try PMing the posters and see if they'll re-post with only the source code.
Thank you for your prompt reply. It's my first post in this forum. Yes , i mean post #19 or #29 and correct my post. Thank a again.