Results 1 to 13 of 13

Thread: Panel sent-to-back don't work

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219

    Question Panel sent-to-back don't work

    I want to design panels at design time; however, when I right click on the panel and click sent-to-back the panel behind this panel doesn't appear. It seems nothing happen with the sent-to-back or bring-to-front option.

    Many thanks in advance for the help.

    ljCharlie

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I'm using VS.NET 2003 , and it's working well .

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219
    It works now. The problem I had was because I didn't change the underlying form to IsMdiContainer=true before I created the panels.

    ljCharlie

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    It shouldn't make much difference though . . good it's working now .

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219
    That's what I thought too but what I have to do is deleted the already created panels and recreate them.

    By the way, since it seems you know a lot about vb.net, how do I call a class within another class? Well, here's what I'm trying to do. I am trying to organize my codes a bit since I don't want too many codes just within one form.vb, so I decided that I'm going to add another class so I can put some of my codes into that class. The problem is I don't know how to execute another class once the main class has been executed. Another question I have is, is this the best way to do? What other alternatives besides adding another class?

    Many thanks for your help.

    ljCharlie

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I'm not sure If I know a lot about VB.NET as you said but I'll try to help .

    Well , as I understand it , you want to move your code in the form to a class file . Then call your functions from the form . right ?

    If so , then it's better to mark your functions asPublic Shared so that you can call it from anywhere without instantiating it . Clear ?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219
    Let's said I have a class name Computers and in this class I have the Paint function to load my data from a database mdb file into a datagrid. How do I call this in my main form? Another question, the event function Paint will have to be declared as Public shared, correct? Because I think by default it is created as Private Sub.

    Again, thanks for the help.

    ljCharlie

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This demo should answer your questions .It's commented also .

    For the second question , the default in functions and sub is Public I guess . And you have to make it public so that you can call it within your form .
    Attached Files Attached Files

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219
    Many thanks for your help. I will take a look at the demo.

    ljCharlie

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219
    Pirate, I have another question. I believed your demo was created under VB.NET 2003 that's why I wasn't able to open it. However, I was able to open the individual .vb files. Still, I have one more question. I have a datagride in, let's say frmMain, but how do I access this datagrid's properties in another class, let's say clsComputer? When I'm creating a public function to load the data from a datbase mdb file into frmMain's datagrid1, how do I do that? Here's what I have tried access in the clsComputer class:

    Public Class clsComputer
    Private Shared mdbPath As String = Application.StartupPath & "\Computers.mdb"
    Dim clsMain As frmMain
    Dim CompDG As DataGrid = clsMain.dgComputer
    Public Function ComputerDG()
    Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & mdbPath
    Dim strSQL As String = "SELECT * FROM Computer"
    Dim compDataAdapter As New OleDbDataAdapter(strSQL, strConn)
    Dim compDataSet As New DataSet()
    Dim ts As New DataGridTableStyle()

    compDataSet.Clear()
    compDataAdapter.Fill(compDataSet, "CompDevices")
    CompDG.DataSource = compDataSet.Tables!CompDevices

    'GET CURRENCY MANAGER
    Dim cm As CurrencyManager

    cm = CType(clsMain.BindingContext(compDataSet.Tables!CompDevices), CurrencyManager)

    'CREATE DATAGRIDSTYLES AND MODIFY

    ts = New DataGridTableStyle(cm)
    ts.GridColumnStyles(0).HeaderText = "Serial#"
    ts.GridColumnStyles(0).Alignment = HorizontalAlignment.Center
    ts.GridColumnStyles(0).ReadOnly() = True
    ts.GridColumnStyles(1).Alignment = HorizontalAlignment.Center
    ts.GridColumnStyles(1).ReadOnly() = True
    ts.GridColumnStyles(2).Alignment = HorizontalAlignment.Center
    ts.GridColumnStyles(2).ReadOnly() = True
    ts.GridColumnStyles(3).HeaderText = "Date Purchased"
    ts.GridColumnStyles(3).Alignment = HorizontalAlignment.Center
    ts.GridColumnStyles(3).ReadOnly() = True
    ts.GridColumnStyles(3).Width() = 100
    CompDG.TableStyles.Add(ts)
    End Function
    End Class
    But I received an error:

    An unhandled exception of type “System.NullReferenceException’ occurred in Devices.exe

    Additional information: Object reference not set to an instance of an object.
    If I declared
    Dim clsMain As frmMain as Dim clsMain As New frmMain then I don't receive any error, the problem now is that the data does not load from the database mdb file into the datagrid in the frmMain form.

    ljCharlie

  11. #11
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    If I were you I wouldn't do it the way you have done . Tell you why ? First , you are nothing making use of the function again . Second , You're not making any sense of OOP here . Here is the ideal solution :
    VB Code:
    1. Public Class clsComputer
    2.  
    3. Public Shared Sub ComputerDG(ByVal MYfrm As Form , ByVal MYDataGrid As DataGrid)
    4.  
    5. Dim mdbPath As String = Application.StartupPath & "\Computers.mdb"
    6. Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & mdbPath
    7. Dim strSQL As String = "SELECT * FROM Computer"
    8. Dim compDataAdapter As New OleDbDataAdapter(strSQL, strConn)
    9. Dim compDataSet As New DataSet()
    10. Dim ts As New DataGridTableStyle()
    11.  
    12. compDataSet.Clear()
    13. compDataAdapter.Fill(compDataSet, "CompDevices")
    14. MYDataGrid.DataSource = compDataSet.Tables!CompDevices
    15.  
    16. 'GET CURRENCY MANAGER
    17. Dim cm As CurrencyManager
    18.  
    19. cm = CType(MYfrm.BindingContext(compDataSet.Tables!CompDevices), CurrencyManager)
    20.  
    21. 'CREATE DATAGRIDSTYLES AND MODIFY
    22.  
    23. ts = New DataGridTableStyle(cm)
    24. ts.GridColumnStyles(0).HeaderText = "Serial#"
    25. ts.GridColumnStyles(0).Alignment = HorizontalAlignment.Center
    26. ts.GridColumnStyles(0).ReadOnly() = True
    27. ts.GridColumnStyles(1).Alignment = HorizontalAlignment.Center
    28. ts.GridColumnStyles(1).ReadOnly() = True
    29. ts.GridColumnStyles(2).Alignment = HorizontalAlignment.Center
    30. ts.GridColumnStyles(2).ReadOnly() = True
    31. ts.GridColumnStyles(3).HeaderText = "Date Purchased"
    32. ts.GridColumnStyles(3).Alignment = HorizontalAlignment.Center
    33. ts.GridColumnStyles(3).ReadOnly() = True
    34. ts.GridColumnStyles(3).Width() = 100
    35. CompDG.TableStyles.Add(ts)
    36. End Function
    37. End Class



    Then call it like this from your form :

    VB Code:
    1. ComputerDG(frmMain , yourdatagrid on the form)

    not tested though...

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219

    Thumbs up

    Perfect! It works! I should've thought of passing the form and the datagrid through the function. I was too concentratedon the class and not the function it self.

    Many thanks for your help again.

    ljCharlie

  13. #13
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Glad to be helpful ...

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