Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2011
    Messaggi
    5

    [WPF] problema di conversione da C a VB

    ho trovato un codice molto interessante però è in C, vorrei trasformarlo in VB.NET....
    DI SEGUITO RIPORTO ANCHE IL CODICE XAML, ESSENDO UN'APPLICAZIONE WPF



    App.xaml
    codice:
    <Application x:Class="DataBind.App"
        xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        StartupUri="Window1.xaml"
        >
        <Application.Resources>
             
        </Application.Resources>
    </Application>
    Window1.xaml.cs
    codice:
    using System;
    using System.Data;
    using MySql.Data.MySqlClient;
    
    namespace DataBind
    {
    
        /// <summary>
        /// Interaction logic for Window1.xaml
        /// </summary>
    
        public partial class Window1 : System.Windows.Window
        {
            public Window1()
            {
                InitializeComponent();
    
                DataTable contentsTable = new DataTable();
    
                 //Set the connection String
                String connString = "server=127.0.0.1;uid=root;pwd=password;database=contents;";
                    
                //Set the query
                String query = "SELECT assetno, item, descr, serialno, purchfrom, manuf FROM contents";
    
                 // Fill the Set with the data
                using (MySqlConnection conn = new MySqlConnection(connString))
                {
                    //Passing the query and connection String
                    MySqlDataAdapter da = new MySqlDataAdapter(query, conn);
                    da.Fill(contentsTable);
                }
    
                 // Set the Data Context
                DataContext = contentsTable;           
            }
        }
    }
    Window1.xaml
    codice:
    <Window x:Class="DataBind.Window1"  
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
       Title="Data Binding Example" Height="220" Width="300"
       WindowStartupLocation="CenterScreen">
        <Grid>  
           <Grid.RowDefinitions>  
              <RowDefinition/>  
              <RowDefinition/>  
              <RowDefinition/>  
              <RowDefinition/>  
              <RowDefinition/> 
                <RowDefinition/>
           </Grid.RowDefinitions>  
          
          <Grid.ColumnDefinitions>  
             <ColumnDefinition Width="75"/>  
             <ColumnDefinition/>  
          </Grid.ColumnDefinitions>  
         
          <Label>Assetno:</Label>  
          <TextBox Grid.Column="1" Text="{Binding Path=assetno}"/>  
          <Label Grid.Row="1">Item:</Label>  
          <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding item}"/>  
          <Label Grid.Row="2">Description:</Label>  
          <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding descr}"/>  
          <Label Grid.Row="3">Serialno:</Label>  
          <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding serialno}"/>  
          <Label Grid.Row="4">Purch. from:</Label>  
          <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding purchfrom}"/> 
          <Label Grid.Row="5">Manuf:</Label>  
          <TextBox Grid.Row="5" Grid.Column="1" Text="{Binding manuf}"/> 
       </Grid>  
    
    </Window>

  2. #2
    Il titolo della discussione non è conforme al regolamento, mandami per favore un messaggio privato con la rettifica.
    Chi non cerca trova.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.