Link to home
Start Free TrialLog in
Avatar of al4629740
al4629740Flag for United States of America

asked on

FlexGrid not sorting/exporting during entering values

I have the attached project.  When I enter a new website name it prompts me to enter into the grid in blue.  After entering the value, it only works if I click on another row.  However, when I push the enter key to accept the value, it does not work.  i would like to also push the enter key and allow the same execution as when I click on another row.
CB.zip
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of al4629740

ASKER

Thank you!
I'm glad I've been able to help you. If you come across any bugs, post them here rather than a new question and I'll be happy to do what I can.
Martin,

I have to make sure that blanks fill ins do not happen on the flexgrid.  For example, if I click Add New and then "decide" not to enter any website, I have a dilemma.  Then I have to push Esc and then find a blank line.  

As a result I get   ^(.*\.)?\.$  

This produces a blank and no blanks should ever exist in the file.

Should I open a new request to fix this?
No, I'll take care of it.
Thank you
I'm also going to add more validation for the website name, because now for example you can enter "aa   aa.com" and get away with it. No new question needed.
Perfect!!

Yes the format only needs to be website.com
Not www.website.com
Please see this short article. I'd like to validate the length of the website name and I assume you want it to be 63 characters or less, but apparently it can be longer. Please let me know what length I should use.

BTW I thought that the "domain" was the part following the last dot, like ".com", but apparently not. Can you tell me what that part of the name is called?
I also found this quote, so I'm happy to add full validation, but I need your guidance as to what I should validate.
Each label may contain up to 63 characters. The full domain name may not exceed the length of 253 characters in its textual representation
BTW I thought that the "domain" was the part following the last dot, like ".com", but apparently not. Can you tell me what that part of the name is called?
I answered my own question here, it's the "top-level domain".
correct, they are called top level domain

btw, the link is in error.  Can you take a look at it
But I see your point anyways.  You are right, domain names do not exceed 63 characters.  So validation only needs to occur at that maximum 63 and at least 2 minimum
Does the 63 include ".com", etc?
I believe not
I'm calling it a night and I may not have a lot of time tomorrow but I won't abandon you.
Thanks Martin.  I'm patient : )
It didn't take as long as I thought it would. This update includes:
Allow Enter to be used to signal completion of the Add Record process
Corrected a bug where when the user changes his mind about adding a new record and presses Esc, a blank record results
Added more website name validations
Disabled some buttons when appropriate
Added a caption to the form
Improved the unsaved changes warning
Here's a heads-up on the last one. The old message which was this
User generated imagebothered me since it was added because it was worded awkwardly and I thought a little confusingly, so I changed it to this. I hope you approve but if not it's easy to undo. Note that the buttons now do the opposite of what they did before.
User generated imageQ-28571318-2.zip
I will try it when I get home later today.  Thank you
Martin.  Great changes!

I noticed one thing.  When I add a record and then change my mind by pushing Esc, then all the buttons are remain disabled and lock me out from doing anything.

See if you get the same issue.  Maybe I'm doing something wrong.
You're probably right. Be back later.
Mia culpa. I made the command button changes at the last minute and obviously didn't fully test.
Q-28571318-3.zip
gratias ago tibi
I reluctantly want to ask for another correction because I would rather just open another question.  

When selecting more than one site using the shift key, I attempt to delete multiple records and get an error.  I think it might be good to just only allow one site to be deleted at a time and this will simplify things.  Should I open another question?

Again thank you for your persistence and help.  You have gone above and beyond.
Let me think about this for a while.
There's no built-in way to limit the number of selected rows to one. I've seen some code on the web that purports to do that but I haven't used any of them and I don't know if they would affect the existing code. There is also no built-in way to know how many rows are selected but I've seen and used code that will allow that to be determined. So we can either try to limit the selection to one row or attempt to allow multiple, contiguous, rows to be deleted. If the latter is your choice then I'd prefer a new question, if you choose the former then I can do it here or in a new question. In either case  (and even if we do neither) we probably should delete the header in the output file if after deletions it has no more websites under it, right?
Deleting one row would be easier and probably cleaner.

Yes, the header could go away, but could also remain to see that there was history there before.
Okay so if you accidentally or on purpose select more than one row how do you want it handled? I  could just reject the selection and say essentially "try again" or I could tell you that I recognize that you've selected more than one but that I'm only going to delete the first one, or...?
Maybe just a message box that says, "only one website can be selected at a time"
In addition to the message I coded it so that the program continues with the deletion of the first row selected. If you'd rather just make the single row selection manually then change

If intEndRow - intStartRow <> 0 Then
    MsgBox "Only one website may be selected at a time", vbInformation + vbOKOnly, "Website Selection Error"
    MSFlexGrid1.RowSel = intStartRow
    'Exit Sub
End If

Open in new window

to this in cmdDelete_Click.
If intEndRow - intStartRow <> 0 Then
    MsgBox "Only one website may be selected at a time", vbExclamation + vbOKOnly, "Website Selection Error"
    MSFlexGrid1.RowSel = intStartRow
    Exit Sub
End If

Open in new window

Q-28571318-4.zip
Thank you Martin.  

When the "Website Selection Error" executes, after clicking OK, then  cmdDelete_Click()  still executes.  Is it possible to prevent cmdDelete_Click() from executing if the "Website Selection Error" is triggered?
When you see the "Pending Deletion" message that follows the "Website Selection Error", just click Cancel rather than OK.
Thats true, but it might get confusing if the user sees OK as an option.  

Is there a way to prevent that from happening on cmdDelete_Click()  so that if there is more than one selection, it simply does not occur?

I think this might be another question to ask?
Change the code as I suggested in post ID: 40472548.
Ahhh.  I should have notice that.  Thanks again!
YW. I'd like to do one more thing before we're done. Right now the program makes note of any change that is made to the list of websites (by setting a flag) and gives a warning about unsaved changes if the flag has been set. It also however records things like starting to add a new record but changing your mind as a change, and that would result in a false warning message if that were the only "change" made.  I realized after I did that that a much better way would be to just save a list of the websites when they are initially loaded and when exiting to compare the saved list to the list that was going to be Exported, and if there's any difference display the warning. That will eliminate the false "change" that I referred to earlier. Would you like me to do that?
Martin,  

Thanks for noticing the details.  If possible, could you please do that?  
Another question?
Martin,

Test the project again and see if you get an error on the double click event
My apologies. Before I fix that I have a few things I want to ask you about.
1.    If the user double-clicks a row making it blue, changes the text and then clicks the "X" (without having pressed Enter or selecting another row), should that trigger the "unsaved changes" warning?
2.    If the file contains ^(.*\.)?hsd1.il.com.comcast.net$, what do you want to see on the screen? In other words what is editable? It would be easier if it were always hsd1.il.com.comcast.net or always comcast.net. If it is the latter, is there always just one dot?
3.    California has a lot of sites like http://www.blah.ca.gov (all ending in ca.gov). If that site were in the allowed list, would it look like ^(.*\.)?blah.ca\.gov$ or would it look like  ^(.*\.)?blah\.ca.gov$? What I'm asking is if there can be more than one dot in the part following the "\" in the allowed website records.
Martin,

I just saw your message.  Thanks for the follow up.

You made me think about another question.  Let me find out about #2 and #3 and get back to you soon on this post

Al
Martin,

1) When I double click a row, I get an error.  Could you see it if you get an error on the double click event?

2) hsd1.il.com.comcast.net should be listed on the flexgrid.  

3)  It should actually be written as ^(.*\.)?blah\.ca\.gov$

I just learned that all regex statements should be \.  in place of .
So hsd1.il.com.comcast.net above would be written also as ^(.*\.)?hsd1\.il\.comcast\.net$
1) When I double click a row, I get an error.  Could you see it if you get an error on the double click event?
You reported that as a problem in post ID: 40473055 and in post ID: 40474083 I said I'd fix it, but before we get to that I want to clear up the design.

2) hsd1.il.com.comcast.net should be listed on the flexgrid.
I interpret that to mean that everything to the right of the question mark in all entries should be shown and editable.

So hsd1.il.com.comcast.net above would be written also as ^(.*\.)?hsd1\.il\.comcast\.net$
Does that mean the the input will be like that, or do you just want it to be written out like that?
1) Ok

2) That is correct.  everything to the right of the question mark.

3)  The previous way works fine.  But I learned that to be exactly correct, every period to the right of question mark should be \.  instead of . when it is written back to the allowed file.

Hopefully I explained it.  Let me know if I need to clarify more.
I understand that the output should be \. but will the input be that way?
Yes, it should be.  The original file I gave you incorrectly had it written.
This app was developed piecemeal and as a result it's messy, so I'm rewriting it. It may take me a day or two to do it and to test it thoroughly.
Martin

Much appreciated!!!!
It just dawned on me that the "Import" button isn't needed and that when the program starts its should  just open the file, so I'm going to delete that button.
Good Point.
OK, here's the new version. Testing included:
Adding a record
Make sure ";ALLOW_MISCELLANEOUS_r<date>" header is added when adding a record
Make sure a header for a given day is added only once
Changing mind during add via the esc key
Adding multiple records (one at a time)
Add a record and then change it
Add a record and then delete another record
Delete a record
Try to delete more than one at the same time
Delete two records, one at a time
Change a record
Change mind during change
While I feel that I've thoroughly tested it, I encourage you to do the same. And if you do then please hold up on reporting problems until you are finished testing.
Rewrite.zip
I will test it tonight.  I may need help on the BlockedSite form also in a separate question

Thank you!!
Very good.  Couple issues I found after messing with it for some time.

1) When entering a website name without a top-level domain such as "test", it gives the message : This website must have a top-level domain.  But after if you click on the cell, the field accepts the invalid site as "test".  Instead can it simply stay in "blue box mode" until corrected?  Or any other way to fix it.

2) If I type add another website with the same name, it gives me the message box that I can't, but still allows the entry to be accepted after clicking OK.  Can this also stay blue until corrected?

3) If I double click a row to edit the website and then change my mind by clicking on another row, it gives me the error that this website already exists.  When I click on a different row, it correctly shows the same error again.  After that, if I double click on another row, it adds a duplicate website name. (I doubt this will be a real issue, but I'm really trying to stress test this.  The issue might be resolved by adding, "Push Esc to leave this record")

3) Export should probably say "Save Changes" instead
Hope this does it.
Rewrite-1.zip
LOOKING GOOD!
That's GOOD:) Can you give me a heads up on the help you need on the BlockedSite form, and let me know how this form relates to that one?
Sure, let me post up a new question