Appunti Liberi di Informatica
Il codice è garantito esente da errori che ove presenti saranno prontamente
rimossi previa segnalazione ed accertamento.
In nessun caso potrò essere ritenuto responsabile per danni diretti e/o indiretti
dovuti ad un errata elaborazione di codice e/o parte di esso.
C# Rilevare se il codice viene eseguito dall´IDE VS
10/02/2012
if (System.Diagnostics.Debugger.IsAttached) {
//...
}
C# GridView Paging
03/02/2012
//Aspx GridView
AllowPaging="True"
PageSize="15"
OnPageIndexChanging="GridMain_PageIndexChanging"
//C#
protected void GridMain_PageIndexChanging(object sender, GridViewPageEventArgs e) {
GridView grid = (GridView)sender;
grid.PageIndex = e.NewPageIndex;
grid.DataBind();
}
C# GridView CommandName Edit Delete
03/02/2012
//Aspx GridView
DataKeyNames="IdField"
OnRowDeleting="GridMain_RowDeleting"
OnRowUpdating="GridMain_RowUpdating"
//C#
protected void GridMain_RowDeleting(object sender, GridViewDeleteEventArgs e) {
GridView grid = (GridView)sender;
int id = int.Parse(grid.DataKeys[e.RowIndex].Value.ToString());
}
protected void GridMain_RowUpdating(object sender, GridViewUpdateEventArgs e) {
GridView grid = (GridView)sender;
int id = int.Parse(grid.DataKeys[e.RowIndex].Value.ToString());
}
C# Singola istanza
03/02/2012
//...
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
//...
static class Program {
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);
[STAThread]
static void Main() {
bool createdNew = true;
using (Mutex mutex = new Mutex(true, "NomeApplicazione", out createdNew)) {
if (createdNew) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
else {
Process current = Process.GetCurrentProcess();
foreach (Process process in Process.GetProcessesByName(current.ProcessName)) {
if (process.Id != current.Id) {
SetForegroundWindow(process.MainWindowHandle);
break;
}
}
}
}
}
}
SQL Update From
03/02/2012
UPDATE Tabella1
SET T1.Campo = T2.Campo
FROM Tabella1 T1
INNER JOIN Tabella2 T2 ON T1.Campo = T2.Campo
Varie Linux Mandriva 2011 Rimuovere pacchetti inutilizzati
08/01/2012
- run /usr/sbin/remove-unused-packages
#: /usr/sbin/remove-unused-packages
C# Ricava nome mese GetMonthName
06/12/2011
public string GetMonthName(int month) {
DateTime date = new DateTime(1900, month, 1);
return date.ToString("MMMM");
}
Varie Schema colori cavo lan
02/12/2011
Cavo Diritto Cavo Cross
1 | B ARANCIO | B VERDE
2 | ARANCIO | VERDE
3 | B VERDE | B ARANCIO
4 | BLU | BLU
5 | B BLU | B BLU
6 | VERDE | ARANCIO
7 | B MARRONE | B MARRONE
8 | MARRONE | MARRONE
C# Linq Sequence contains no element
18/11/2011
Cast
Table tb = (Table)Context.Table.SingleOrDefault(item => item.ID == id)
Context
using (DatabaseContainer db = new DatabaseContainer()) {
Table tb = db.Table.SingleOrDefault(item => item.ID == id);
// ...
}
Per maggiori informazioni compilare il modulo alla sezione Contatti
Categorie
Condividi
Ti sono stato utile?
Offrimi una birra!