An absolute cracker of a nerdy post by James Iry, author of One Div Zero.
See it here: A Brief, Incomplete, and Mostly Wrong History of Programming Languages
Couldn't agree more with 1996-2001 =P
Mainly notes to future-Twig (and for anyone else who may find them useful)
If you've found one or more of my blog posts helpful, why not say thanks by buying me a coffee or beer?
An absolute cracker of a nerdy post by James Iry, author of One Div Zero.
See it here: A Brief, Incomplete, and Mostly Wrong History of Programming Languages
Couldn't agree more with 1996-2001 =P
When you call a dialog with dlg.ShowDialog() and check the result, you may find it always returning DialogResult.Cancel.
private void AddItem()
{
FormAdd dlgAdd = new FormAdd();
DialogResult res = dlgAdd.ShowDialog(this);
if (res != DialogResult.OK)
{
return;
}
// All good to go here
} So with your dialog, ensure that the correct "AcceptButton" property has been set to the correct button.
A simple mistake to make is to forget setting the result when you click OK/Save/etc.
private void btnAdd_Click(object sender, EventArgs e)
{
// Do some validation here
this.DialogResult = DialogResult.OK;
} That should set the correct value by the time the dialog is closed.
ListViewItem lvi = new ListViewItem();
lvi.UseItemStyleForSubItems = false;
//Declare a new delegate specific to updating the text of a label
delegate void UpdateLabelTextDelegate(Label lbl, string text);
//This method will invoke the delegate and pass our args along
void UpdateLabelText(Label lbl, string text)
{
UpdateLabelTextDelegate dlg = new UpdateLabelTextDelegate(UpdateLabelTextByDelegate);
//Invoke this method on the control's original that owns the label's handle
lbl.Invoke(dlg, new object[] { lbl, text });
}
//This method is invoked by our delegate and actually updates the label text
void UpdateLabelTextByDelegate(Label lbl, string text)
{
lbl.Text = text;
}
//Call the method now
UpdateLabelText(myLabel, "What a great post");
What a waste of time just to change a frikken label!pbarLoading.Invoke((MethodInvoker)delegateShort sweet and simple!
{
pbarLoading.Value++;
});