Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. does everybody know how to deal with this question?

does everybody know how to deal with this question?

Scheduled Pinned Locked Moved Visual Basic
questionsalestutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lisana
    wrote on last edited by
    #1

    This is my datagrid table: Entity_id customer phone address 1 name 222 2 name2 333 3 name3 444 button: show entity_id when you select which row, then that row's entity_id pass to the button, when you click the button, then popup messagebox to tell you what entity_id you select.. is everybody has any idea to do this function? - Lisa

    S 1 Reply Last reply
    0
    • L Lisana

      This is my datagrid table: Entity_id customer phone address 1 name 222 2 name2 333 3 name3 444 button: show entity_id when you select which row, then that row's entity_id pass to the button, when you click the button, then popup messagebox to tell you what entity_id you select.. is everybody has any idea to do this function? - Lisa

      S Offline
      S Offline
      skytribe
      wrote on last edited by
      #2

      Perhaps this is what you are looking for.... Get the current cell's rownumber and then build string for the messagebox which looks at the appropriate columns on that cell..... Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strTest As String Dim iRowNumber As Integer Try iRowNumber = DataGrid1.CurrentCell.RowNumber() strTest = "Selected Identify " & CStr(DataGrid1.Item(iRowNumber, 1)) MessageBox.Show(strTest) Catch ex As Exception End Try End Sub SkyTribe

      L 1 Reply Last reply
      0
      • S skytribe

        Perhaps this is what you are looking for.... Get the current cell's rownumber and then build string for the messagebox which looks at the appropriate columns on that cell..... Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strTest As String Dim iRowNumber As Integer Try iRowNumber = DataGrid1.CurrentCell.RowNumber() strTest = "Selected Identify " & CStr(DataGrid1.Item(iRowNumber, 1)) MessageBox.Show(strTest) Catch ex As Exception End Try End Sub SkyTribe

        L Offline
        L Offline
        Lisana
        wrote on last edited by
        #3

        thanks SkyTribe.. But that is not I'm dealing with in my appl. I need the entityID whick is clicked to forward to another form to the next SQL: select * from customer where entity_id = entityID... Lisa

        A 1 Reply Last reply
        0
        • L Lisana

          thanks SkyTribe.. But that is not I'm dealing with in my appl. I need the entityID whick is clicked to forward to another form to the next SQL: select * from customer where entity_id = entityID... Lisa

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          Then how about this.... Public Class MainForm Inherits System.Windows.Forms.Form Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm3 As New Form3 With frm3 .ID = TextBox1.Text .Show() End With End Sub End Class and a sub form containing a single label control. Public Class Form3 Inherits System.Windows.Forms.Form Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim strTest As String strTest = "Item Selected = " & mvarID Label1.Text = strTest End Sub Private mvarID As String Public Property ID() As String Get Return mvarID End Get Set(ByVal Value As String) mvarID = Value End Set End Property End Class With this the contents of textbox (but it could be any items on the mainform are used to set properties on the sub form (frm3) which are then used in frm3. In this case there is a single label called label1 on the sub form which is set from the contents of the textbox on mainform. If you wanted to pass a integer then simply change the property to integer. If you wanted to pass a series of integer for say a SQL select statement then you could construct a where clause sting on the main and pass a single string or pass a collection or data structure of integer values to the sub form to be parsed into a sql string.

          L 1 Reply Last reply
          0
          • A Anonymous

            Then how about this.... Public Class MainForm Inherits System.Windows.Forms.Form Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm3 As New Form3 With frm3 .ID = TextBox1.Text .Show() End With End Sub End Class and a sub form containing a single label control. Public Class Form3 Inherits System.Windows.Forms.Form Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim strTest As String strTest = "Item Selected = " & mvarID Label1.Text = strTest End Sub Private mvarID As String Public Property ID() As String Get Return mvarID End Get Set(ByVal Value As String) mvarID = Value End Set End Property End Class With this the contents of textbox (but it could be any items on the mainform are used to set properties on the sub form (frm3) which are then used in frm3. In this case there is a single label called label1 on the sub form which is set from the contents of the textbox on mainform. If you wanted to pass a integer then simply change the property to integer. If you wanted to pass a series of integer for say a SQL select statement then you could construct a where clause sting on the main and pass a single string or pass a collection or data structure of integer values to the sub form to be parsed into a sql string.

            L Offline
            L Offline
            Lisana
            wrote on last edited by
            #5

            This is my code.. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim objConn As String = "Provider=SQLOLEDB;Data Source=server;" Dim objString As String = "SELECT entity_id, client_number, client_name FROM Companies WHERE status=1" Dim DA As OleDbDataAdapter Dim DS As DataSet Dim conn As New OleDbConnection(objConn) DA = New OleDbDataAdapter(objString, objConn) DS = New DataSet DA.Fill(DS, "Companies") conn.Close() DataGrid1.DataSource = DS.Tables("Companies") 'how to get the entity_id when user select client_number row? how to sign the entity = ?? End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'messagebox test if pass the right entity_id MessageBox.Show(entity) dim form2 as new form2 form2.showdialog() End Sub Public Class Form2 Inherits System.Windows.Forms.Form Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim objConn As String = "Provider=SQLOLEDB;Data Source=server;" Dim objString As String = "SELECT client_number, client_name, contact, phone_number, address, city FROM Companies WHERE status=1 and entity_id = " & entity Dim DA As OleDbDataAdapter Dim DS As DataSet Dim conn As New OleDbConnection(objConn) DA = New OleDbDataAdapter(objString, objConn) DS = New DataSet DA.Fill(DS, "Companies") conn.Close() DataGrid1.DataSource = DS.Tables("Companies") End Sub Lisa

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups