Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Field details
Message
De
06/07/2006 07:11:21
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
06/07/2006 02:08:53
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
Divers
Thread ID:
01133895
Message ID:
01134075
Vues:
16
No I didn't and you're right. I expected what should naturally be there to be there:)
MessageBox.Show( (string)((DataRowView)dr.DataBoundItem).Row["town"] );
// or
MessageBox.Show( ((myDS.myTbRow)((DataRowView)dr.DataBoundItem).Row).town );
// or if you know the index
MessageBox.Show((string)dr.Cells[index].Value);
BindingSource sounded to be a better alternative to me too. However unless I was doing it wrong it is no less work. Would you share the syntax? Mine looked like:
string v1 = ((myDS.myTbRow)((DataRowView)myTbBindingSource.Current).Row).town;
string v2 = (string)((DataRowView)myTbBindingSource.Current).Row["town"];
Both doesn't look like less work than using dr.DataBoundItem. dr.DataBoundItem and myTbBindingSource.Current both point to same thing.
Probably I could never find the appropriate syntax. There should be an easier and direct way:)
Cetin

>
DataGridViewRow dr = myDataGridView.CurrentRow;
>MessageBox.Show( (string)dr["town"]
>
>Hi, Cetin...
>
>Just a side-note, did you try that code? I still use the BindingContext position and the current view of the source data, but I gave it a try.
>
>I got an error as well - unless I'm missing something, the DataGridViewRow object doesn't seem to have a direct indexer. I had to do the following:
>
>
>
DataGridViewRow dr = myDataGridView.CurrentRow;
>MessageBox.Show(  Convert.ToString( dr.Cells["MyColDataGridViewTextBoxColumn"]));
>
>                           // is the "GridViewTextBoxColumn needed?   Don't know
>
>// or
>
>MessageBox.Show(  Convert.ToString( dr.Cells[ColNumber]));
>
>
>At any rate, I still prefer the binding context (assuming it's bound data). Plus which, I don't think the DataGridViewRow will work if you want to reference a column in the source data that isn't displayed in the grid.
>
>Kevin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform