datagridview / cells and rows

hi,

i need help, how can i get the value from a particular dgvcell if i'll select the entire dgvrow and how to auto-select a row




Answer this question

datagridview / cells and rows

  • Ray Angeles

    Try:

    newTempProductRow =
    (
    this.tblHwCompProductsBindingSource.Current as DataRowView).Row
    as product_dbDataSetComp.Tbl_HW_ProductsRow;

    Might want to try checking for nulls

    if ( !this.tblHwCompProductsBindingSource.Current == null )
    newTempProductRow =
    (
    this.tblHwCompProductsBindingSource.Current as DataRowView).Row
    as product_dbDataSetComp.Tbl_HW_ProductsRow;



  • RJ

    mark the answer



  • Ali Gullen

    newTempProductRow = (product_dbDataSetComp.Tbl_HW_ProductsRow) this.tblHwCompProductsBindingSource.Current;

    something like that im a bit lost at the min....


  • Ahmed_khemiri

    Hi, am trying to do the same thing, where im pulling some info from within a record. am using the binding source.current to get the obj. but im getting stuck on how to cast to a dataTableRow.

    Can anyone help me

    Thanks.


  • SilentAcorn

    Look at BindingSource.position

  • peter_griffin

    oh yeah. . .

    if your grid is bound to a binding source which is inturn bound to an IList, at any given time, BindingSource.Position will return the index of the currently selected item in your IList

    BindingSource.Current gives the actual selected item though you will have to cast it to the particular item. if your ilist is a Dataable, you will need to cast it to a DataTableRow



  • Alfy

    thats brilliant got it working now.

    super fast reply.

    Thanks!


  • Chequer

    thanks I got it..

  • HighDesert_NM

    it may be a DataRowView.

    not in a place i can check, but put a breakpoint there and inspect it using a watch. it will tell you what class it is.



  • datagridview / cells and rows