Results 1 to 14 of 14

Thread: SGrid help with editing cells

  1. #1

    Thread Starter
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Exclamation SGrid help with editing cells

    Hi everyone, I have been using S Grid in my app and its been working great. Now I am trying to do something though I havent done before with SGrid, editing the cells. In the new grid I have created I have 2 columns. One column shows the titles/captions and the other is all the cells that I want to editable. I set the grid Editable property to true and I have the following code:
    VB Code:
    1. Private Sub DetailsGrid_SelectionChange(ByVal lRow As Long, ByVal lCol As Long)
    2.  
    3.     If lCol = 2 Then
    4.         DetailsGrid.StartEdit(lRow, lCol) = True
    5.     End If
    6.  
    7. End Sub
    When I run the project and if I click anywhere on the grid I get the following error: "Assignment to constant not permitted"..
    Any Suggestions?? Thanx everyone for the help!

  2. #2

    Thread Starter
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Re: SGrid help with editing cells

    I am thinking it probably isnt having to really do with editing SGrid because if I put a watch on lCol, lCol doenst equal anything, it states <Can't Compile Module> in as the value.

    Anyone know what could be causing this?

  3. #3
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: SGrid help with editing cells

    Did you first try their editing example ?

    I just ran it and it lets me click in the email cell and change it, ok.

    I have attached it.
    Attached Files Attached Files
    Rob C

  4. #4
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: SGrid help with editing cells

    I notice in that example they use a different event, than the one you used.
    VB Code:
    1. Private Sub grdEdit_RequestEdit(ByVal lRow As Long, ByVal lCol As Long, ByVal iKeyAscii As Integer, bCancel As Boolean)
    Rob C

  5. #5

    Thread Starter
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Re: SGrid help with editing cells

    I will glance at the example thanx for that. But lCol should be giving me a value...I dont see why it isnt. If it was to give me a value I am sure it would work. Here is a link to their site about the different edit properties. They do mention the Request Edit event but they dont explain anything about it..

  6. #6
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: SGrid help with editing cells

    My memory ain't what it used to be, so this may be incorrect.
    I have a vague recollection of using a similar event to yours in some other grid, and was getting thwarted by some col or row value not updating until a bit later in the event sequence.
    Rob C

  7. #7

    Thread Starter
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Re: SGrid help with editing cells

    Yea, I think it just aint updating quick enough. The other grid I use, I am using a SelectionChange event and I can use lCol and lRow variables...

  8. #8
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: SGrid help with editing cells

    ANYONE INTERESTED IN TRYING THE ABOVE EXAMPLE ?

    All you will need to get the Edit Example zip above, working is this other attachment -
    Install_SGrid2_and_ImageList_Unzip_Me_and_run_Setup_exe.zip

    If you go to this link and look down near the bottom, you will find that zip file.
    Re SGrid Help
    (The attachment is about 8 post up from the bottom)

    It installs a couple of controls, and a DLL (SSubTmr6.dll) that you can read up on at the VBAccelerator web site.

    The example should then run easily on your system.

    I also use that installer on my clients computers.
    I don't install my programs (they use only a couple of controls), I just give them the exe.
    When I decided to use the SGRid2, I created that stand alone installer, which I run once only on their computers.

    Trust me,
    Rob C

  9. #9

    Thread Starter
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Re: SGrid help with editing cells

    Would like to follow up on Rob's post. His installer worked very easy and the SGrid control works perfect on my home computer.

    Someone else you can trust, =P

  10. #10

    Thread Starter
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Re: SGrid help with editing cells

    The project you have attached Rob has a missing control. So I am going to attach it to this post.
    Attached Files Attached Files

  11. #11
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: SGrid help with editing cells

    The sequence of events that works for me, is the following...

    With an SGrid called Grid1 and a text box called txtEdit and
    VB Code:
    1. Grid1.Editable = true
    1. Code request an edit of a row and a column using
    VB Code:
    1. Grid1.StartEdit mNextRowToEdit, mNextColToEdit
    When Grid1_RequestEdit fires (this code section is available directly in the demo code that comes with the grid) it positions the text box over the cell (this may need the odd tweak if you are resizing your grid) and makes it visible.

    2. The user enters the text value for the new grid cell and hits enter.

    3. txtEdit_Keypress is firing all the time that text is being added to the txtbox, but the procedure only really needs to respond to the keyAscii value of 13. At this point the second thing you do in the txtEdit_Keypress event is end the editing session with
    VB Code:
    1. Grid1.Endedit = true
    This is necessary, because unless you do this ( as you will see later) the cell edit will NOT refire.

    4. Grid1_PreCanceledit is called (because you have ended the edit in (3)) and it is here you evaluate the text that has been entered in the text box. If you are happy with it you ..

    a. Update the grid with the new value
    b. Stash the new value into you program somewhere, If the grid is fronting a database then you need to do an SQL to update your base records.

    Cancel edit fires and the text box becomes hidden.

    If you are unhappy with what has been entered into the text box set the variable
    VB Code:
    1. bStayInEditMode = True
    The Cancel is itself Cancelled and crutially the texEdit text box is left visible.

    5. Picking up in (3) again. The events of 4 kick off when you call the line
    VB Code:
    1. Grid1.Endedit = true
    immediately after this line you can make the decision.
    VB Code:
    1. If txtEdit.Visible = False then
    2.     'Point to the next cell you want to edit (normally the one below, but you could go to the next column)
    3.     ....
    4.     ....
    5.     Grid1.StartEdit mNextRowToEdit, mNextColToEdit     ' Starts it all again
    6.     Else
    7.     ' You are still editing the same cell.  Bring up an error message here if you like.
    8.     ' Something along the lines of " Numeric data only please"
    9.     Endif
    And that as they say in the trade is that.

    HTH
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  12. #12

    Thread Starter
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Re: SGrid help with editing cells

    Ok, I understand how editing works for S Grid now. =) Im still having the same problem though with the selection change event....any suggestions on how I can get it to work and why it isnt giving lCol or lRow a value? And is mNextRowToEdit, mNextColToEdit your own made up variables?

  13. #13

    Thread Starter
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Re: SGrid help with editing cells

    Ok, never mind, I guess putting "()" around lRow, lCol was producing the error...now I will try and get the editing part finished. Thank all for the help!

  14. #14
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: SGrid help with editing cells

    The project you have attached Rob has a missing control. So I am going to attach it to this post.
    Thank you.

    If anyone wishes me to re-create the Installer with that control included, just post to this thread.
    Rob C

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width