Click here to Skip to main content
15,907,183 members
Home / Discussions / C#
   

C#

 
Questionproper Async reading operation Pin
Chesnokov Yuriy5-Nov-09 4:25
professionalChesnokov Yuriy5-Nov-09 4:25 
AnswerRe: proper Async reading operation Pin
Jimmanuel5-Nov-09 5:55
Jimmanuel5-Nov-09 5:55 
GeneralRe: proper Async reading operation Pin
Chesnokov Yuriy5-Nov-09 8:28
professionalChesnokov Yuriy5-Nov-09 8:28 
QuestionAssembly redirection in .NET Pin
KarthikonIT5-Nov-09 4:18
KarthikonIT5-Nov-09 4:18 
AnswerRe: Assembly redirection in .NET Pin
Not Active5-Nov-09 5:43
mentorNot Active5-Nov-09 5:43 
QuestionTransparency Pin
stancrm5-Nov-09 3:43
stancrm5-Nov-09 3:43 
AnswerRe: Transparency Pin
The Man from U.N.C.L.E.5-Nov-09 7:38
The Man from U.N.C.L.E.5-Nov-09 7:38 
QuestionHelping -- winpcap & winDump libraries for capture and dump IP packets using C# Pin
3bood.ghzawi5-Nov-09 2:21
3bood.ghzawi5-Nov-09 2:21 
Questionsizeof struct with array Pin
Ronenb5-Nov-09 2:03
Ronenb5-Nov-09 2:03 
AnswerRe: sizeof struct with array Pin
Luc Pattyn5-Nov-09 2:23
sitebuilderLuc Pattyn5-Nov-09 2:23 
GeneralRe: sizeof struct with array Pin
Ronenb7-Nov-09 19:16
Ronenb7-Nov-09 19:16 
GeneralRe: sizeof struct with array Pin
Luc Pattyn8-Nov-09 1:07
sitebuilderLuc Pattyn8-Nov-09 1:07 
GeneralRe: sizeof struct with array Pin
Ronenb8-Nov-09 4:36
Ronenb8-Nov-09 4:36 
QuestionSplit Name Field Pin
kruegersck5-Nov-09 1:58
kruegersck5-Nov-09 1:58 
AnswerRe: Split Name Field Pin
musefan5-Nov-09 2:30
musefan5-Nov-09 2:30 
AnswerRe: Split Name Field Pin
Shameel5-Nov-09 2:33
professionalShameel5-Nov-09 2:33 
AnswerRe: Split Name Field Pin
V.5-Nov-09 4:21
professionalV.5-Nov-09 4:21 
AnswerRe: Split Name Field Pin
PIEBALDconsult5-Nov-09 5:34
mvePIEBALDconsult5-Nov-09 5:34 
GeneralRe: Split Name Field Pin
Luc Pattyn5-Nov-09 12:51
sitebuilderLuc Pattyn5-Nov-09 12:51 
QuestionHow to Hide MenuBar/ToolBar while displaying Office Document using Web Browser? Pin
muhammad_umair5-Nov-09 1:22
muhammad_umair5-Nov-09 1:22 
QuestionIs there a better way for updating bound controls when updating the data source manually? Pin
TheFoZ5-Nov-09 0:40
TheFoZ5-Nov-09 0:40 
AnswerRe: Is there a better way for updating bound controls when updating the data source manually? Pin
Gerry Schmitz5-Nov-09 15:34
mveGerry Schmitz5-Nov-09 15:34 
GeneralRe: Is there a better way for updating bound controls when updating the data source manually? Pin
TheFoZ5-Nov-09 22:23
TheFoZ5-Nov-09 22:23 
GeneralRe: Is there a better way for updating bound controls when updating the data source manually? Pin
Gerry Schmitz6-Nov-09 6:57
mveGerry Schmitz6-Nov-09 6:57 
Sorry about that; didn't realize those methods were protected.

Here is a solution that works: use the DataBindings ReadValue and WriteValue methods; eg.


<pre>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1 {
   public partial class Form1 : Form {

         private TextBox fistNameTextBox =
            new TextBox() { Location = new Point( 0, 0 ) };
         private TextBox lastNameTextBox =
            new TextBox() { Location = new Point( 0, 30 ) };

         private Button readButtom = new Button() {
            Location = new Point( 0, 70 ),
            AutoSize = true,
            Text = "Read from Source"
         };

         private Person aPerson = new Person();

         public Form1() {

            readButtom.Click += new EventHandler( readButtom_Click );

            fistNameTextBox.DataBindings.Add( new Binding( "Text", aPerson, "FirstName" ) );
            lastNameTextBox.DataBindings.Add( new Binding( "Text", aPerson, "LastName" ) );

            this.Controls.AddRange( new Control[] {
                  fistNameTextBox, lastNameTextBox, readButtom } );
         }

         void readButtom_Click( object sender, EventArgs e ) {

            aPerson.FirstName = "John";
            aPerson.LastName = "Smith";

            foreach ( Control control in this.FindForm().Controls ) {
                  if ( control is TextBox && control.DataBindings.Count > 0 )
                     control.DataBindings[ 0 ].ReadValue();
            }
         }

         [STAThread]
         static void Main() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault( false );
            Application.Run( new Form1() );
         }

         public class Person {
            public string FirstName { get; set; }
            public string LastName { get; set; }
         }
   }
}</pre>
AnswerRe: Is there a better way for updating bound controls when updating the data source manually? Pin
TheFoZ9-Nov-09 23:13
TheFoZ9-Nov-09 23:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.