Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

displaying in a text box

Can anyone give me some advice on displaying a certain field in a textbox? I have a datagrid that has customers and in the textbox I need to display their order count in. I can display it by clicking the plus sign next to the record.... Please help!!

Comments

  • GogiGogi Member Posts: 258
    : Can anyone give me some advice on displaying a certain field in a textbox? I have a datagrid that has customers and in the textbox I need to display their order count in. I can display it by clicking the plus sign next to the record.... Please help!!
    :
    :

    Well,what do you mean by "order count"?
    If it's just the number of rows in your table you can get it using RecordCount property:
    [code]
    TextBox1.Text=CStr(ADO.Recordset.RecordCount)
    [/code]
  • ldn769ldn769 Member Posts: 18
    It isn't the number of rows, it is a field in a sub-table that was created by writing a select statement in the DataAdapter...

    SELECT
    COUNT(customerid) AS OrderCount,
    CustomerID
    FROM
    Orders
    GROUP BY
    CustomerID

    I know that I need to use the datagrid_currentcellchanged formula to make it work, but I don't how.... But I did need to know how to do the recordcount as well so thanks!!

    : : Can anyone give me some advice on displaying a certain field in a textbox? I have a datagrid that has customers and in the textbox I need to display their order count in. I can display it by clicking the plus sign next to the record.... Please help!!
    : :
    : :
    :
    : Well,what do you mean by "order count"?
    : If it's just the number of rows in your table you can get it using RecordCount property:
    : [code]
    : TextBox1.Text=CStr(ADO.Recordset.RecordCount)
    : [/code]
    :

  • GogiGogi Member Posts: 258
    [b][red]This message was edited by Moderator at 2005-7-27 10:32:49[/red][/b][hr]
    [b][red]This message was edited by Moderator at 2005-7-27 10:31:45[/red][/b][hr]
    : It isn't the number of rows, it is a field in a sub-table that was created by writing a select statement in the DataAdapter...
    :
    : SELECT
    : COUNT(customerid) AS OrderCount,
    : CustomerID
    : FROM
    : Orders
    : GROUP BY
    : CustomerID
    :
    : I know that I need to use the datagrid_currentcellchanged formula to make it work, but I don't how.... But I did need to know how to do the recordcount as well so thanks!!
    :
    : : : Can anyone give me some advice on displaying a certain field in a textbox? I have a datagrid that has customers and in the textbox I need to display their order count in. I can display it by clicking the plus sign next to the record.... Please help!!
    : : :
    : : :
    : :
    : : Well,what do you mean by "order count"?
    : : If it's just the number of rows in your table you can get it using RecordCount property:
    : : [code]
    : : TextBox1.Text=CStr(ADO.Recordset.RecordCount)
    : : [/code]
    : :
    :
    :

    Hi,

    I didn't know you are using VB.NET.Because of it,you won't be able to use Recordset.RecordCount.Instead of it,use this code:
    [code]
    TextBox1.Text=DataSet1.Tables("NameOfYourTable").Rows.Count.ToString
    [/code]

    And about getting the selected row..I think you should use a code like this:

    [code]
    'Put this in global scope (on top of your form code):
    Public old_row As Integer = -1

    Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridInst.CurrentCellChanged
    Dim new_row As Integer
    new_row = DataGrid1.CurrentRowIndex

    If old_row <> new_row And new_row >= 0 Then
    old_row = new_row

    MsgBox("Row changed!", MsgBoxStyle.Information)
    End If
    End Sub

    'The following sub will get the selected row if user makes any changes to the DataSource (i.e. deletes the record):
    Private Sub DataGrid1_DataSourceChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridInst.DataSourceChanged
    GridInst_CurrentCellChanged(Nothing, Nothing)

    End Sub
    [/code]

    Hope this helps!







  • ldn769ldn769 Member Posts: 18
    Yeah!! Thanks a bunch!

    Lindsay
Sign In or Register to comment.