Solved

placing variable in textbox when adding a  new record

Posted on 2010-11-29
23
451 Views
Last Modified: 2012-05-10
sql server express 2005 sp3
vb.net 2008
I have a data collection for with textboxes from sql server table
binding navigator controls on form.

I have a public variable that takes the current value in a textbox and saves it in memory.

When I add a new record...I want this variable to be placed in the same field with the variable value...

 Private mlngData1 As Object  ' Customer Mfrnumber

when saving a record...

mlngData1 = Me.FldCmfrnumTextBox.Text

when adding a new record...

I then do:
Me.FldCmfrnumTextBox.Select()
Me.FldCmfrnumTextBox.Text = mlngData1   ' Customer Mfrnumber


 But it will not place the value in the textbox...


Thanks
fordraiders
0
Comment
Question by:fordraiders
  • 14
  • 3
  • 3
  • +2
23 Comments
 
LVL 7

Assisted Solution

by:Rommel Sultan
Rommel Sultan earned 125 total points
ID: 34234634
Can you try this

Me.FldCmfrnumTextBox.Text = Val(mlngData1)
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34235596
rsultan, sorry did not work.
0
 
LVL 17

Expert Comment

by:Zhaolai
ID: 34235970
Have you assigned a new value to mlngData1 before updating the textbox? Place a breakpoint at the line:
Me.FldCmfrnumTextBox.Text = mlngData1   ' Customer Mfrnumber
to see if the value of mlngData1 has changed.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 3

Author Comment

by:fordraiders
ID: 34236229
well, did the breakpoint thing and the value of the textbox in debugger is
"0"...?
But the variable value had not changed..

So instead of assigning the field the value of the variable...its giving it a value of  "0" in memory but not placing anything on the form.

Thanks
fordraiders
0
 
LVL 17

Assisted Solution

by:Zhaolai
Zhaolai earned 125 total points
ID: 34236250
What is the value of FldCmfrnumTextBox.Text at the following line:
mlngData1 = Me.FldCmfrnumTextBox.Text

What is the value of mlngData1 at the following line:
Me.FldCmfrnumTextBox.Text = mlngData1
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34236389
ok lets say I'm at record 36
In the bindingnavigator...I hit "Add Record"

The value in Me.FldCmfrnumTextBox.Text
 = "apples"
mlngData1 = Me.FldCmfrnumTextBox.Text
mlngData1 = "apples"

at this point...
Me.FldCmfrnumTextBox.Text = mlngData1
mlngData1 at this point is still "apples"

The variable is holding its value but the textbox simply will not accept the Var(mlngData1) value.
0
 
LVL 4

Assisted Solution

by:barnesd1
barnesd1 earned 125 total points
ID: 34238843
'Don't use Object use String:
Private sData1 As String  ' Customer Mfrnumber

'when saving a record...
sData1 = Me.FldCmfrnumTextBox.Text

'when adding a new record...
Me.FldCmfrnumTextBox.Select()
Me.FldCmfrnumTextBox.Text = sData1   ' Customer Mfrnumber
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34238939
barnesd1,
still a no , but thanks...
I can almost see in a flash the value being placed there but then it gets wiped out.
I have no other events occuring after this statements.

when you are using a binding navigator is there an event that occurs after you a new record is being added.?
In other words the vents that occur after you press the "+" sign on the binding navigator toolbar on the form.
Because no code is there to begin with ?

My "Main id" field on my form shows "-1" , until I press "Save"

Thanks
fordraiders

0
 
LVL 3

Author Comment

by:fordraiders
ID: 34239060
do the databindings have anything to do with the textbox accepting values during a dataset editing ?
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34239114
If I do this:
Me.txtCmfrnum.DataBindings.Clear()

before the record is added...

The value will be placed in in the textbox...

but the problem then is binding back the textbox to the database ?

because this does not completely bind the textbox back.

txtCmfrnum.DataBindings.Add("Text", ICart_DataDataSet, _
            "tblMainData.fldCmfrnum")
0
 
LVL 4

Expert Comment

by:barnesd1
ID: 34239146
The textbox you are trying to load into, is that a databound one or a standard textbox.  Cos if databound it may get overwritten by what's in the database.
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34239309
its databound...because I'm using the bindingnavigator...
I dragged and dropped my fields from the datasourcde explorer window...

so your saying if in sql server express table the defualt value is set to "Null" it will get overwritten ?

0
 
LVL 4

Expert Comment

by:barnesd1
ID: 34239364
When do you expect the database save/commit to occur.  Suggest you post bigger section of code
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34239470
all the code I have thus far in the form is below...
Thanks;
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Windows.Forms.Form
Imports System.Windows.Forms.DataGridView
Imports System.Windows.Forms.Control
Imports System.Windows.Forms.ColumnHeader
Imports System.ComponentModel
Imports System.Runtime.InteropServices
Imports System.Configuration
Imports System.Configuration.ConfigurationSettings
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Collections
Imports System.Collections.Specialized
Imports System.Diagnostics
Public Class frmEnterpriseCollection
    Private con As New SqlConnection
    Private dxt As DataTable
    Private sql_command As SqlCommand
    Private sql_param As SqlParameter
    Private dxa As SqlDataAdapter
    ' daragrid 2
    Private con2 As New SqlConnection
    Private dxt2 As DataTable
    Private sql_command2 As SqlCommand
    Private sql_param2 As SqlParameter
    Private dxa2 As SqlDataAdapter
    ' datagrid 3
    Private Con3 As New SqlConnection
    Private dxt3 As DataTable
    Private sql_command3 As SqlCommand
    Private sql_param3 As SqlParameter
    Private dxa3 As SqlDataAdapter

    ' datagrid view for scan/num mfgnames in grid
    ' mfgname ScanNumName 
    Private sql_param31 As SqlParameter
    Private sql_param15 As SqlParameter
    Private sql_command15 As SqlCommand
    Private sql_command31 As SqlCommand
    Private dxa31 As SqlDataAdapter
    Private Con31 As New SqlConnection
    Private dxt31 As DataTable
    ' Bring Items Forward
    Private mlngData1 As Object  ' Customer Mfrnumber
    Private mlngData2 As Object  ' Customer Mfgname
    Private mlngData3 As Object  ' Customer Partnumber
    Private mlngData4 As Object  ' Program
    Private mlngData5 As Object  ' Unit
    Private mlngData6 As Object  ' Level
    Private mlngData7 As Object  ' Position
    Private mlngData8 As Object  ' Compartment
    Private mlngData9 As Object  ' Customer Description
    Private mlngData10 As Object ' Product Notation
    Private mlngData11 As Object ' Site Collector


    Private Sub TblMainDataBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblMainDataBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.TblMainDataBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.ICart_DataDataSet)
        
        SaveForward()
    End Sub

    Private Sub frmEnterpriseCollection_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
        ' FORCE UPPER ON ALL CASES
        If Char.IsLower(e.KeyChar) Then
            e.KeyChar = Char.ToUpper(e.KeyChar)
        End If
    End Sub

    Private Sub frmEnterpriseCollection_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DataSetCollector.tblCollector' table. You can move, or remove it, as needed.
        Me.TblCollectorTableAdapter.Fill(Me.DataSetCollector.tblCollector)
        'TODO: This line of code loads data into the 'DataSetMfgname.tblMfgnames' table. You can move, or remove it, as needed.
        Me.TblMfgnamesTableAdapter.Fill(Me.DataSetMfgname.tblMfgnames)
        'TODO: This line of code loads data into the 'ICart_DataDataSet.tblMainData' table. You can move, or remove it, as needed.
        Me.TblMainDataTableAdapter.Fill(Me.ICart_DataDataSet.tblMainData)
        ' loading datagridview1
        ' SAP Cross Reference  DatagridView1 
        con.ConnectionString = "Data Source=.\sqlexpress;Initial Catalog=DescMatchGisXref;User ID=sa;Password=veeger"
        con.Open()
        sql_command = New SqlCommand("get_View_SAP_Data_Grid1", con)
        sql_command.CommandType = CommandType.StoredProcedure
        sql_param = sql_command.Parameters.Add("@param3", SqlDbType.NVarChar)
        dxa = New SqlDataAdapter(sql_command)
        ' LOADING DATAGRID VIEW2
        ' Grainger SKU VIEW DATAGRIDView2 
        con2.ConnectionString = "Data Source=.\sqlexpress;Initial Catalog=WwgExtra;User ID=sa;Password=veeger"
        con2.Open()
        sql_command2 = New SqlCommand("get_Sku_View_DataGrid2", con2)
        sql_command2.CommandType = CommandType.StoredProcedure
        sql_param2 = sql_command2.Parameters.Add("@param4", SqlDbType.NVarChar)
        dxa2 = New SqlDataAdapter(sql_command2)

        ' LOADING DATAGRID VIEW3
        ' gRainger Parts_SKU VIEW DATAGRIDVIEW3 
        Con3.ConnectionString = "Data Source=.\sqlexpress;Initial Catalog=gPartsFindMro;User ID=sa;Password=veeger"
        Con3.Open()
        sql_command3 = New SqlCommand("get_GFSku_View_DataGrid3", Con3)
        sql_command3.CommandType = CommandType.StoredProcedure
        sql_param3 = sql_command3.Parameters.Add("@param5", SqlDbType.NVarChar)
        dxa3 = New SqlDataAdapter(sql_command3)


        ' loading datagridview1
        ' SAP VIEW GRID1 FOR MFGNAME 
        Con31.ConnectionString = "Data Source=.\sqlexpress;Initial Catalog=DescMatchGisXref;User ID=sa;Password=veeger"
        Con31.Open()
        sql_command31 = New SqlCommand("get_ScanNamNum_CollectionScreen", Con31)
        sql_command31.CommandType = CommandType.StoredProcedure
        sql_param15 = sql_command31.Parameters.Add("@param15", SqlDbType.NVarChar)
        sql_param31 = sql_command31.Parameters.Add("@param31", SqlDbType.NVarChar)
        dxa31 = New SqlDataAdapter(sql_command31)

        ' go to the Last Record
        Me.TblMainDataBindingSource.MoveLast()

    End Sub

    Private Sub FldCmfrnumTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles FldCmfrnumTextBox.KeyDown
        Dim I As Integer
        If e.KeyCode = Keys.Enter Then
            e.SuppressKeyPress = True
            ' Me.Cursor = Cursors.WaitCursor

            ' e.SuppressKeyPress = True
            sql_param.Value = FldCmfrnumTextBox.Text
            dxt = New DataTable
            dxa.Fill(dxt)
            DataGridView1.DataSource = dxt

            ' NEW CODE ADDED 
            ' GET A RECORD COUNT
            i = dxt.Rows.Count
            If i = 0 Then
                Me.Cursor = Cursors.Default
                MsgBox("No Records Found")
            End If
            Dim s As String
            s = Me.ComboBox1.Text


            ' DataGridView1.Sort(DataGridView1.Columns(s), System.ComponentModel.ListSortDirection.Ascending)
            DataGridView1.Sort(DataGridView1.Columns("MFRNUM"), System.ComponentModel.ListSortDirection.Ascending)




            If Me.ComboBox1.Text = "MFRNUM" Then
                DataGridView1.Sort(DataGridView1.Columns("MFRNUM"), System.ComponentModel.ListSortDirection.Ascending)
            End If
            If Me.ComboBox1.Text = "MFRNAME" Then
                DataGridView1.Sort(DataGridView1.Columns("MFRNAME"), System.ComponentModel.ListSortDirection.Ascending)
            End If

            If Me.ComboBox1.Text = "XREF" Then
                DataGridView1.Sort(DataGridView1.Columns("XREF"), System.ComponentModel.ListSortDirection.Ascending)
            End If


            ' if we do find some records
            Me.Cursor = Cursors.Default
            If My.Settings.ColumnOrders IsNot Nothing Then

                For j As Integer = 0 To My.Settings.ColumnOrders.Count - 1
                    Dim index As Integer = Convert.ToInt32(My.Settings.ColumnOrders(j))
                    Me.DataGridView1.Columns(j).DisplayIndex = index
                Next
            End If

            If My.Settings.dgvColumnWidth <> String.Empty Then
                Dim x As Integer
                For Each col As String In My.Settings.dgvColumnWidth.Split(";"c)
                    Me.DataGridView1.Columns(x).Width = col
                    x += 1
                Next
            End If

            sql_param3.Value = FldCmfrnumTextBox.Text
            dxt3 = New DataTable
            dxa3.Fill(dxt3)
            DataGridView3.DataSource = dxt3
            Me.DataGridView1.Select()

        End If


        ' needs to be fixed !  october 2010

        If Me.chkScanName.Checked = True Then

            ' e.SuppressKeyPress = True
            sql_param15.Value = FldCmfrnumTextBox.Text
            sql_param31.Value = FldCmfgnameComboBox.Text
            dxt31 = New DataTable
            dxa31.Fill(dxt31)
            DataGridView1.DataSource = dxt31

            If My.Settings.ColumnOrders IsNot Nothing Then

                For j As Integer = 0 To My.Settings.ColumnOrders.Count - 1
                    Dim index As Integer = Convert.ToInt32(My.Settings.ColumnOrders(j))
                    Me.DataGridView1.Columns(j).DisplayIndex = index
                Next
            End If

            If My.Settings.dgvColumnWidth <> String.Empty Then
                Dim x As Integer
                For Each col As String In My.Settings.dgvColumnWidth.Split(";"c)
                    Me.DataGridView1.Columns(x).Width = col
                    x += 1
                Next
            End If

            sql_param3.Value = FldCmfrnumTextBox.Text
            dxt3 = New DataTable
            dxa3.Fill(dxt3)
            DataGridView3.DataSource = dxt3
            Me.DataGridView1.Select()
        End If
    End Sub

    Public Sub SaveForward()
        mlngData1 = Me.FldCmfrnumTextBox.Text   ' Customer Mfrnumber
        mlngData2 = Me.FldCmfgnameComboBox.Text  ' Customer Mfgname
        mlngData3 = Me.FldCPnumberTextBox.Text  ' Customer Partnumber
        mlngData4 = Me.FldProgramTextBox.Text  ' Program
        mlngData5 = Me.FldUnitTextBox.Text  ' Unit
        mlngData6 = Me.FldLevelTextBox.Text  ' Level 
        mlngData7 = Me.FldPositionTextBox.Text  ' Position
        mlngData8 = Me.FldCompartmentTextBox.Text  ' Compartment
        mlngData9 = Me.FldCdescriptionTextBox.Text  ' Customer Description
        mlngData10 = Me.FldProductNotationTextBox.Text ' Product Notation
        mlngData11 = Me.FldAssociateComboBox.Text ' Site Collector
    End Sub

    Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
        'TblMainDataBindingSource.RemoveCurrent()
        'TblMainDataBindingSource.EndEdit()
    End Sub

    Private Sub BindingNavigatorAddNewItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
        SaveForward()
        Test1()

    End Sub
    Private Sub Test1()

        ' place values in textbox
        If Me.CheckBox1.Checked = True Then
            Me.FldCmfrnumTextBox.Text = mlngData1   ' Customer Mfrnumber
        End If
        If Me.CheckBox2.Checked = True Then
            Me.FldCmfgnameComboBox.Text = mlngData2   ' Customer Mfrname
        End If
        If Me.CheckBox3.Checked = True Then
            Me.FldCPnumberTextBox.Text = mlngData3   ' Customer PartNumber
        End If
        If Me.CheckBox4.Checked = True Then          ' Position
            Me.FldProgramTextBox.Text = mlngData4
        End If
        If Me.CheckBox5.Checked = True Then          ' Unit
            Me.FldUnitTextBox.Text = mlngData5
        End If
        If Me.CheckBox6.Checked = True Then          'Level
            Me.FldLevelTextBox.Text = mlngData6
        End If
        If Me.CheckBox7.Checked = True Then          ' Position
            ' Me.FldPositionTextBox.Text = mlngData7
            If Me.CheckBox9.Checked = True Then
                Me.FldPositionTextBox.Text = mlngData7  ' Position
                Dim arg As Char = FldPositionTextBox.Text
                If Char.IsLetter(arg) Then
                    Dim value As Integer = AscW(arg)
                    Select Case value
                        Case 65 To 89, 97 To 121
                            FldPositionTextBox.Text = ChrW(value + 1).ToString
                    End Select
                End If

                If Char.IsNumber(arg) Then
                    Dim value As Integer = CInt(FldPositionTextBox.Text)
                    Select Case value
                        Case Is > 0 ' or Case 1 To 1000 
                            value += 1
                            FldPositionTextBox.Text = value.ToString
                            If Me.FldPositionTextBox.Text = "1" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
                            If Me.FldPositionTextBox.Text = "2" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
                            If Me.FldPositionTextBox.Text = "3" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
                            If Me.FldPositionTextBox.Text = "4" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
                            If Me.FldPositionTextBox.Text = "5" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
                            If Me.FldPositionTextBox.Text = "6" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
                            If Me.FldPositionTextBox.Text = "7" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
                            If Me.FldPositionTextBox.Text = "8" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
                            If Me.FldPositionTextBox.Text = "9" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
                    End Select
                End If

            End If

        Else
            ' else not checked
            '            Me.FldPositionTextBox.Clear()
        End If


        If Me.CheckBox8.Checked = True Then          ' Compartment
            ' Me.FldCompartmentTextBox.Text = mlngData8
            If Me.CheckBox10.Checked = True Then
                Me.FldCompartmentTextBox.Text = mlngData8  ' Compartment
                Dim arg As Char = FldCompartmentTextBox.Text

                If Char.IsLetter(arg) Then
                    Dim value As Integer = AscW(arg)
                    Select Case value
                        Case 65 To 89, 97 To 121
                            FldCompartmentTextBox.Text = ChrW(value + 1).ToString
                    End Select
                End If

                If Char.IsNumber(arg) Then
                    Dim value As Integer = CInt(FldCompartmentTextBox.Text)
                    Select Case value
                        Case Is > 0 ' or Case 1 To 1000 
                            value += 1
                            FldCompartmentTextBox.Text = value.ToString
                            If Me.FldCompartmentTextBox.Text = "1" Then FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
                            If Me.FldCompartmentTextBox.Text = "2" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
                            If Me.FldCompartmentTextBox.Text = "3" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
                            If Me.FldCompartmentTextBox.Text = "4" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
                            If Me.FldCompartmentTextBox.Text = "5" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
                            If Me.FldCompartmentTextBox.Text = "6" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
                            If Me.FldCompartmentTextBox.Text = "7" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
                            If Me.FldCompartmentTextBox.Text = "8" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
                            If Me.FldCompartmentTextBox.Text = "9" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
                    End Select
                End If

            End If
        Else
            ' else not checked
            ' FldCompartmentTextBox.Clear()
        End If


        If Me.CheckBox11.Checked = True Then          ' Description
            Me.FldCdescriptionTextBox.Text = mlngData9
        End If
        If Me.CheckBox12.Checked = True Then         ' Product Notation
            Me.FldProductNotationTextBox.Text = mlngData10
        End If
        If Me.CheckBox13.Checked = True Then        ' Collector
            Me.FldAssociateComboBox.Text = mlngData11
        End If

    End Sub

    Private Sub btnDataview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDataview.Click
        If frmDataView.Visible = True Then
            frmDataView.BringToFront()
        Else
            frmDataView.Show()
        End If
    End Sub

    Private Sub FldGraingerTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FldGraingerTextBox.TextChanged
        Try
            sql_param2.Value = FldGraingerTextBox.Text
            dxt2 = New DataTable
            dxa2.Fill(dxt2)
            DataGridView2.DataSource = dxt2
        Catch

        End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If MessageBox.Show("Are you are sure you want to Post An Functional Match?", _
                       "Posting Functional Match.", _
       MessageBoxButtons.YesNo) = DialogResult.Yes Then

            ' POSTING FOR XREF FUNCTIONAL
            FldCmfrnumTextBox.Text = DataGridView1.CurrentRow.Cells(0).Value.ToString() ' Customer Part Number
            'txtMfrname.Text = DataGridView1.CurrentRow.Cells(1).Value.ToString()
            '  cboMfgnames.Text = DataGridView1.CurrentRow.Cells(1).Value.ToString()
            FldCdescriptionTextBox.Text = DataGridView1.CurrentRow.Cells(2).Value.ToString()
            FldGraingerTextBox.Text = DataGridView1.CurrentRow.Cells(3).Value.ToString()
            ' MIGHT HAVE TO PUT ON CONDITION ON GRID "O"
            FldXrefTypeTextBox.Text = "F"
            FldSalesStatusTextBox.Text = DataGridView1.CurrentRow.Cells(5).Value.ToString()
            FldAlt1TextBox.Text = DataGridView1.CurrentRow.Cells(9).Value.ToString()

        End If
        Me.FldCmfrnumTextBox.Select() ' mfrnumber select
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If MessageBox.Show("Are you are sure you want to Post An Exact Match?", _
                      "Posting Functional Match.", _
      MessageBoxButtons.YesNo) = DialogResult.Yes Then
            ' POSTING FOR XREF ON EXACT
            FldCmfrnumTextBox.Text = DataGridView1.CurrentRow.Cells(8).Value.ToString() ' 
            'txtMfrname.Text = DataGridView1.CurrentRow.Cells(7).Value.ToString() '
            FldCmfgnameComboBox.Text = DataGridView1.CurrentRow.Cells(7).Value.ToString() '
            FldCdescriptionTextBox.Text = DataGridView1.CurrentRow.Cells(2).Value.ToString() '
            FldGraingerTextBox.Text = DataGridView1.CurrentRow.Cells(3).Value.ToString() '
            ' MIGHT HAVE TO PUT ON CONDITION ON GRID "O"
            FldXrefTypeTextBox.Text = "E" '
            FldSalesStatusTextBox.Text = DataGridView1.CurrentRow.Cells(5).Value.ToString()  '
            FldAlt1TextBox.Text = DataGridView1.CurrentRow.Cells(9).Value.ToString()  '
        End If
        Me.FldCmfrnumTextBox.Select() ' mfrnumber select
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        If MessageBox.Show("Are you are sure you want to Post An Functional Match?", _
                       "Posting Functional Match.", _
       MessageBoxButtons.YesNo) = DialogResult.Yes Then
            ' POSTING FOR GRAINGER SKU ON FUNCTIONAL
            FldCdescriptionTextBox.Text = DataGridView2.CurrentRow.Cells(3).Value.ToString()
            FldGraingerTextBox.Text = DataGridView2.CurrentRow.Cells(0).Value.ToString()
            ' MIGHT HAVE TO PUT ON CONDITION ON GRID "O"
            FldXrefTypeTextBox.Text = "F"
            FldSalesStatusTextBox.Text = DataGridView2.CurrentRow.Cells(2).Value.ToString()
            FldAlt1TextBox.Text = DataGridView2.CurrentRow.Cells(5).Value.ToString()
        End If
        Me.FldCmfrnumTextBox.Select() ' mfrnumber select
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        If MessageBox.Show("Are you are sure you want to Post An Exact Match?", _
                     "Posting Functional Match.", _
     MessageBoxButtons.YesNo) = DialogResult.Yes Then


            ' POSTING FOR EXACT ON GRAINGER SKU
            FldCmfrnumTextBox.Text = DataGridView2.CurrentRow.Cells(14).Value.ToString() ' 
            'txtMfrname.Text = DataGridView2.CurrentRow.Cells(12).Value.ToString()
            FldCmfgnameComboBox.Text = DataGridView2.CurrentRow.Cells(13).Value.ToString()
            FldCdescriptionTextBox.Text = DataGridView2.CurrentRow.Cells(3).Value.ToString()
            FldGraingerTextBox.Text = DataGridView2.CurrentRow.Cells(0).Value.ToString()
            ' MIGHT HAVE TO PUT ON CONDITION ON GRID "O"
            FldXrefTypeTextBox.Text = "E"
            FldSalesStatusTextBox.Text = DataGridView2.CurrentRow.Cells(2).Value.ToString()
            FldAlt1TextBox.Text = DataGridView2.CurrentRow.Cells(5).Value.ToString()

        End If
        Me.FldCmfrnumTextBox.Select() ' mfrnumber select
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        If MessageBox.Show("Are you are sure you want to Post An Functional Match?", _
                      "Posting Functional Match.", _
      MessageBoxButtons.YesNo) = DialogResult.Yes Then

            ' POSTING FOR GPARTS FINDMRO
            FldCmfrnumTextBox.Text = DataGridView3.CurrentRow.Cells(0).Value.ToString() ' 
            '  txtMfrname.Text = DataGridView1.CurrentRow.Cells(1).Value.ToString() '
            FldCmfgnameComboBox.Text = DataGridView3.CurrentRow.Cells(1).Value.ToString() '
            FldCdescriptionTextBox.Text = DataGridView3.CurrentRow.Cells(2).Value.ToString() '
            FldGraingerTextBox.Text = DataGridView3.CurrentRow.Cells(3).Value.ToString() '
            ' MIGHT HAVE TO PUT ON CONDITION ON GRID "O"
            FldXrefTypeTextBox.Text = "G"
            FldSalesStatusTextBox.Text = "GPARTS"
            FldAlt1TextBox.Text = ""
        End If
        Me.FldCmfrnumTextBox.Select() ' mfrnumber select
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        ' save the column orders to the Application settings

        If My.Settings.ColumnOrders Is Nothing Then
            My.Settings.ColumnOrders = New System.Collections.Specialized.StringCollection()
        End If
        My.Settings.ColumnOrders.Clear()
        For Each col As DataGridViewColumn In Me.DataGridView1.Columns
            My.Settings.ColumnOrders.Add(col.DisplayIndex.ToString())
            '  My.Settings.ColumnOrders.Add(col.Width.ToString())
        Next
        My.Settings.Save()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If My.Settings.ColumnOrders IsNot Nothing Then

            For j As Integer = 0 To My.Settings.ColumnOrders.Count - 1
                Dim index As Integer = Convert.ToInt32(My.Settings.ColumnOrders(j))
                Me.DataGridView1.Columns(j).DisplayIndex = index
            Next
        End If
    End Sub

    Private Sub BtnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClose.Click
        Me.Close()
    End Sub

    Private Sub FldPositionTextBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles FldPositionTextBox.LostFocus
        If Me.FldPositionTextBox.Text = "1" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
        If Me.FldPositionTextBox.Text = "2" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
        If Me.FldPositionTextBox.Text = "3" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
        If Me.FldPositionTextBox.Text = "4" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
        If Me.FldPositionTextBox.Text = "5" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
        If Me.FldPositionTextBox.Text = "6" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
        If Me.FldPositionTextBox.Text = "7" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
        If Me.FldPositionTextBox.Text = "8" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
        If Me.FldPositionTextBox.Text = "9" Then Me.FldPositionTextBox.Text = "0" + Me.FldPositionTextBox.Text
        ' LostFocusSave()
    End Sub

    Private Sub FldCompartmentTextBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles FldCompartmentTextBox.LostFocus
        If Me.FldCompartmentTextBox.Text = "1" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
        If Me.FldCompartmentTextBox.Text = "2" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
        If Me.FldCompartmentTextBox.Text = "3" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
        If Me.FldCompartmentTextBox.Text = "4" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
        If Me.FldCompartmentTextBox.Text = "5" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
        If Me.FldCompartmentTextBox.Text = "6" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
        If Me.FldCompartmentTextBox.Text = "7" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
        If Me.FldCompartmentTextBox.Text = "8" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
        If Me.FldCompartmentTextBox.Text = "9" Then Me.FldCompartmentTextBox.Text = "0" + Me.FldCompartmentTextBox.Text
        '  LostFocusSave()
    End Sub
    

End Class

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34239746
What happens if you type the value into the textbox instead of programmtically? Does it persist?
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34239896
Codecruiser, Yes it does...
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 125 total points
ID: 34239963
Try the code suggested here. Instead of Rows(0), use Rows(Rows.Count - 1)

http://www.experts-exchange.com/Programming/Languages/.NET/Q_20797315.html
0
 
LVL 3

Accepted Solution

by:
fordraiders earned 0 total points
ID: 34240496
codecruiser,
ok...after doing some reading...from this thread...
http://social.msdn.microsoft.com/forums/en-us/vblanguage/thread/5BE9D6C3-39EA-4730-A582-D89A4A79F94A

I thought I might try and directly interface with the binding source properties...

Private Sub TblMainDataBindingSource_CurrentChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TblMainDataBindingSource.CurrentChanged
        Test1()
    End Sub

test1 is a sub from above code...

It is bringing  the value forward now and persisting the change nto the database table when hitting the "Save"...
button !

Problem is I don't completely understand why ?






0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34240545
I have seen this problem before where programmatic changes to bound controls are not persisted. It could be classed as a bug probably.
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34240669
The only thing I can figure the "current changed"  event method of the binging sourcde must be firing after the bindings are complete..which is I think my problem from the get go...

I don't really know...mystery to me right now...
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34240689
To All,

well  2 problems now...I don't know how to score this and I'll let ya know if any problems arise from what I have done thus far !
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34242765
I solved the questrion but all were good reading solutions
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 34276781
Thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question