Joao 0

Joao 0

  • NA
  • 1
  • 2.5k

How do I get the ComboBox to show always as 1 element the element with the same name as the user

Aug 16 2010 7:39 AM
This is the code:

 string strConn = (@"Data Source=MY-PC;Initial Catalog=RgpNews;Integrated Security=True;Trusted_Connection=True;connection timeout=30;");
SqlConnection conn = new SqlConnection(strConn);
             try
             {
                conn.Open();
                string selecttable = String.Format(@"SELECT [IdName], [Name] FROM [RgpNews].[dbo].[Users]");
                SqlDataAdapter da = new SqlDataAdapter(selecttable, conn);
                SqlCommandBuilder cmdBldr = new SqlCommandBuilder(da);
                //da.Fill(dt);
                DataTable datat = new DataTable();
                da.Fill(datat);
                comboPaisesbox.DisplayMemberPath = "Name";
                comboPaisesbox.SelectedValuePath = "IdName";
                comboPaisesbox.DataContext = datat;


XMAL Code is;

 <ComboBox Text="Users" x:Name="comboUserbox" Grid.Column="1" HorizontalAlignment="Left" Margin="7,5,0,5" Grid.Row="4" ItemsSource="{Binding}" VerticalAlignment="Center" IsSynchronizedWithCurrentItem="{x:Null}" ToolTip="Select the user." IsReadOnly="True" />

Regards,

Answers (1)