CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2011
    Location
    Buenos Aires, Argentina
    Posts
    130

    CCGrid column double click error

    Hi! I'm having a little problem with a CCGrid object.

    When a form loads, I fill the grid with data from a SQL Recordset, columns and rows get created and I get my form with all the data in it. So far so good. The thing is, if the first thing I do after the load finishes is double click on the column resize line, I get an error 5: invalid procedure of arguments.

    If I click on anything on the form, then everything works ok, it's just if the very first thing I do is double click on a column border. The eventual action would be to auto-size the column width, which I'm not interested in anyway. But this crashes my program! And you can't expect the user to not double click on the column... if that makes your SW crash, it's the first thing they'll do =)

    I'm initializing the object:

    With CCGrid_Name
    .AllowDelete = True
    .AllowUpdate = True
    .WordWrap = True
    .HeadLines = 1

    Set c = .Columns.Add("Name", "")
    ...
    End With

    I tried (with no effect):

    - setting up a dblclick sub for the grid
    - setting Focus to any object on Form_Load, crashed since object is not visible yet, learned something, tried next
    - setting Focus to any object on Form_activate()
    - simulating a click event in Form_Load
    - simulating a double click event in Form_Activate

    Any ideas? Thanks for the help!

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: CCGrid column double click error

    Not sure but if you think setting the focus would help this can be done in the form load event if you code it properly.

    all you need to do is add a line to make the form visible before you call the setfocus
    Code:
    Private Sub Form_Load()
    
       Me.Visible = True
       Text1.SetFocus
    
    End Sub
    Don't know if that will solve your problem but it will allow to to set the focus to a valid object during form load.

    There is also an option to turn on or off resizing of columns as well as to size the columns during load.
    Last edited by DataMiser; July 5th, 2011 at 12:48 PM.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jun 2011
    Location
    Buenos Aires, Argentina
    Posts
    130

    Re: CCGrid column double click error

    Well, what you suggest is equivalent to setting Focus on Activation of the form, and that didn't help. I tried it anyway, but it crashed again. I also tried setting focus to a few of the objects in the form, including the form itself, but it didn't work either.

    The form is opened by another form, so it seems like the it does not know where to look for when the double click event is called, since the new form is not the active one or something like that. I also tried changing between modal and not modal, no effect.

    There is the possibility to set .AllowUserResizing = MSAllowResizeNone

    This would prevent the crash, but will also limit my software. I could always set a new state for UserResizing inside a click event, so that I make sure it's disabled by activation time, but enabled once I get past the unfortunate first double click. Not the most elegant solution, but still a working workaround.

    Can I enter break mode to whereever it is the event takes me? If I knew where to put a break point then I could try to fix it, but I'm not even sure of what exactly is happening...

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: CCGrid column double click error

    Do you have code in the click event or double click event or if present resize event? Can't tell much from the little bit of code you have posted thus far.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jun 2011
    Location
    Buenos Aires, Argentina
    Posts
    130

    Re: CCGrid column double click error

    Hi, thanks for the reply.

    Actually, there is (or should exist) no click, double click or resize event. The CCGrid has a BeforeUpdate and AfterUpdate event. In case you click on a cell, it automatically changes to it, and in case you double click on one, you enter edit mode if it is not locked. After you change something and hit enter (or change cell), you trigger the Before and After Update events. None of that causes the problem. I've already used that for ages and could always edit everything ok. It's the darn first double click that crashes, and only if you double click on the column border

    I can't post much code since there isn't actually any, sorry! It's more of an object problem rather than code. Or at the most, that's just it, the problem is a lack of code =)

    The form load does not include anything else than what I posted, just more of the same. What I changed now is to add the setting of .AllowUserResize property, and intentionally add the click event to restore the original value of if.

    I'll post the CCGrid properties tomorrow, just to know what their defaults are. Thanks!

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: CCGrid column double click error

    Time to use a different grid...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

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

Featured