At the risk of making this sound like a poker commercial:
I'm snk13 @ bodog.com. Come play with me! :)
cheers
jk
I'm snk13 @ bodog.com. Come play with me! :)
[C#]
public class MyForm : Form
{
[DllImport("user32.dll", CharSet=CharSet.Auto, CallingConvention=CallingConvention.Winapi)]
internal static extern IntPtr GetFocus();
private Control GetFocusedControl()
{
Control focusedControl = null;
// To get hold of the focused control:
IntPtr focusedHandle = GetFocus();
// Note that if the focused Control is not a .Net control,
//then this will return null.
if(focusedHandle != IntPtr.Zero)
focusedControl = Control.FromHandle(focusedHandle);
return focusedControl;
}
}
public List< T > ConvertListToListT< T >(System.Collections.IList list)
{
List< T > ret = new List< T >();
foreach (T o in list)
{
ret.Add(o);
}
return ret;
}
Programmers are optimists. We assume that each feature in the specification
for a project can be added in a constant amount of time even as the code grows,
and we add each new feature just like we added the last. In other words, that
programs are completed in linear time. The last half, recursively, takes twice
as long.
What it is, what it's for, and why you'd use it
“Pretty Good Privacy” (PGP) is a scheme used to encrypt or sign messages. There are other schemes for the same thing, but this one is freely available for various different types of computer systems. It works by using secret and public key pairs, you pass out your public key and keep your secret key, and so does anyone else that you communicate with (they pass out their public keys, and keep their private keys). All the keys, in combination, are used to encrypt messages (your own private keys, and each other's public keys), and all of them are required to decrypt them (you send a message encrypted with your private key and their public key, and they decrypt it with your public key and their private key). This way, no outsider can decrypt the material (because they don't have anybody's private keys).
// right click with treeview doesn't set the selected item. This handler
// does...
private void treeView1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
treeView1.SelectedNode = treeView1.GetNodeAt(e.X, e.Y);
if (treeView1.SelectedNode == null)
{
Console.WriteLine("null");
}
// Convert from tree coordinates to screen coordinates, and then back
// to form coordinates so that the context menu pops up at the right spot...
Point spot = this.PointToClient(treeView1.PointToScreen(new Point (e.X, e.Y)));
this.contextMenu1.Show(this, spot);
}
}
IList list = new ArrayList();
list.Add("the only item in my list");
for(int i = 0; i < list.Count; i++)
{
Console.WriteLine(list[i].ToString()); //using the variable 'i' is goodness
Console.WriteLine(list[1].ToString()); //erroneously using the number 1 instead of 'i' is not goodness
}
[Test]
public void MyUITest()
{
MyForm form = new MyForm();
ComboBox combo1 = GetControl(form, "combo1") as ComboBox;
Assert.IsNotNull(combo1);
Assert.AreEqual(combo1.SelectedValue, "somevalue");
//TODO party on the combo1 control
}
private Control GetControl(Control parent, string name)
{
foreach(Control c in parent.Controls)
{
if(name == c.Name)
return c;
}
return null;
}
dataView.RowFilter = string.Format("{0} LIKE '{1}%'", dataView.Table.Columns[0].ColumnName, quxx);
dataView.RowFilter = string.Format("{0} LIKE '[0-9]%'", dataView.Table.Columns[0].ColumnName, quxx);, but got an invalid expression exception.
dataView.RowFilter = string.Format("SUBSTRING({0}, 1, 1) IN (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)", dataView.Table.Columns[0].ColumnName, quxx);