none
Shrinking Form

    Question

  • Visual Studio Community 15.5.7
    .Net framework 4.7
    Windows 10
    I start a new project, Visual Basic Windows Forms. Enlarge the form in Design mode and add one button.
    This is the code in the button.
    Dim strCon As String = $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={strFileName};Extended Properties=""Excel 12.0;HDR=YES;"""
    Dim cn = New OleDbConnection(strCon)
    cn.Open()
    strFileName is the full path and filename of a valid .xlsx file. (tested elsewhere)
    The form shrinks on cn.Open() No errors. Any ideas?

    Mary

    Tuesday, March 6, 2018 2:25 AM

All replies

  • Hi Mary,

    (1) What do you mean by "The form shrinks"? Is the Form got minimized?
    (2) Did you provide all code in the button? Is there other code than you provided?

    Regards,

    Ashidacchi >> http://hokusosha.com/

    Tuesday, March 6, 2018 2:35 AM
  • Visual Studio Community 15.5.7
    .Net framework 4.7
    Windows 10
    I start a new project, Visual Basic Windows Forms. Enlarge the form in Design mode and add one button.
    This is the code in the button.
    Dim strCon As String = $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={strFileName};Extended Properties=""Excel 12.0;HDR=YES;"""
    Dim cn = New OleDbConnection(strCon)
    cn.Open()
    strFileName is the full path and filename of a valid .xlsx file. (tested elsewhere)
    The form shrinks on cn.Open() No errors. Any ideas?

    Mary


    I believe this would be a question for the Visual Studio or Windows Forms project forums. What happens if you convert the code to C# and run it in a C# project?

    La vida loca

    Tuesday, March 6, 2018 3:28 AM
  • I mean the form gets much smaller, not minimized. There is no other code in the whole project. This was for testing purposes. Just one form, one button and the code posted (excludes the string with the path and file name)

    Mary

    Tuesday, March 6, 2018 10:30 AM
  • Just did it in C# and had the same results. That was a good thought. I would hate to break rules by reposting this in other forums. Is it OK to do duplicate posts? 

    Mary

    Tuesday, March 6, 2018 10:41 AM
  • Hi Mary,

    If there is no other code and the issue occurs, what I can guess is that you are using two PCs. One is for developing and the other is for executing test and they must have different DPI.
    If this guess is correct, make your application DPI-Aware.

    Regards,

    Ashidacchi >> http://hokusosha.com/

    Tuesday, March 6, 2018 10:46 AM
  • Just did it in C# and had the same results. That was a good thought. I would hate to break rules by reposting this in other forums. Is it OK to do duplicate posts? 

    Mary

    Hi Mary, go ahead and post in C#, that is fine.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, March 6, 2018 11:19 AM
    Moderator
  • I mean the form gets much smaller, not minimized. There is no other code in the whole project. This was for testing purposes. Just one form, one button and the code posted (excludes the string with the path and file name)

    Mary

    So what if just MessageBox.Show("Something") was in the button click event sub and not the other code. Does the same thing happen?

    There's also a .Net Framework forum.

    Personally I would post in some of the other forums and link to this thread in the post so others can read this thread in regard to the issue. Perhaps try the C#, Visual Studio and .Net Framework forums since the issue occurs after you select a button and not when the app is launched...


    La vida loca

    Tuesday, March 6, 2018 12:59 PM
  • No, one PC. The shrinking occurs at runtime, when I click the button.

    Mary

    Wednesday, March 7, 2018 11:48 AM
  • La vida loca, commented out cn.Open() and added a MessageBox.Show("Something"). No shrinking.

    Mary

    Wednesday, March 7, 2018 11:54 AM
  • La vida loca, commented out cn.Open() and added a MessageBox.Show("Something"). No shrinking.

    Mary

    Well I have no idea seeing as how I don't know anything about databases and connections for them and such so I would have no understanding of how that could affect a window (in this case a Form) causing it to alter after it is displayed.

    Maybe Kareninstructor would have an idea as she is most proficient with the technology you are using I believe.


    La vida loca

    Thursday, March 8, 2018 12:19 AM