|
You're welcome!
|
|
|
|
|
Hi all developers.
Lately I started working on a library that allows to compose complex asynchronous operations from simple ones using LINQ syntax and extension methods. It can be found here. The idea itself was taken from F# asynchronous workflows, so I don't take any credit for the idea, just for the implementation.
The need occurred when I was working for a company that had an existing server that provided a known set of operations and we needed to write a UI client that the operations it wanted to perform were composition (sequential or parallel) of the server's operations. So instead of writing the ugly code with callbacks and exception handling we came up with this idea.
Here is a simple example for the library's usage:
Async<DataItem[]> operation =
from dataItems1 in provider1.AsyncGetDataItems("data items id")
from dataItems2 in provider2.AsyncGetDataItems(dataItems1)
select dataItems1.Concat(dataItems2).ToArray();
operation.Execute(CompletionCallback);
I would like you to try and and send me any feedback about the design/implementation and of course bug reports.
Thanks!
Alex.
P.S. I Googled it and found out that something already blogged about it. So other people came up with this idea too. I just didn't find a ready-to-use library that people can download and start using, so I decided to write one.
|
|
|
|
|
I want that check box in a datagridview should act like a radio button.Means whenever I select a checkbox it will be selected and rest of all would be deselect.
I have used cellContentClick event of the datagrid view.Structure of the datagridview is like-
1st column is checkbox and 2nd is text box.following is the code i have used-
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (i == e.RowIndex)
{
dataGridView1.Rows[i].Cells[0].Value = true;
}
else
{
dataGridView1.Rows[i].Cells[0].Value = false;
}
}
The above code runs good when i select another checkbox.But when one checkbox is selected/checked and now I again click on the same checkbox then it is deselected/unchecked.I want when the same checkbox is checked again it won't unchecked and remian checked.
How can I do this?
Thanks in adv....
|
|
|
|
|
If you must use checkboxes and not radiobuttons, then you could add something like the following to your call. You will of course want to add some better validation.
for( int i = 0; i < dataGridView1.Rows.Count; i++ )
{
CheckBox ctl = (CheckBox)dataGridView1.Rows[i].FindControl( "CheckBoxControlName" );
if( ctl != null )
{
ctl.Checked = ( i == e.RowIndex );
ctl.Enabled = !( i == e.RowIndex );
}
}
This would simply disable the currently selected checkbox while allowing any other to be selected.
(NOTE: I just hammered this out in the editor. If I have a syntax error or typo... sorry.)
modified on Wednesday, October 13, 2010 2:50 PM
|
|
|
|
|
You can do that by changing readonly property as below.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (i == e.RowIndex)
{
dataGridView1.Rows[i].Cells[0].Value = true;
dataGridView1.Rows[i].Cells[0].ReadOnly = true;
}
else
{
dataGridView1.Rows[i].Cells[0].Value = false;
dataGridView1.Rows[i].Cells[0].ReadOnly = false;
}
}
}
|
|
|
|
|
Hi.
I created a User Control.In load event it adds some text Boxes on it.
I built it and added its DLL to my toolbox.
1:I want to change those Text box on the User Control at design time after adding it on my form.
2:Or when i add this user control to my form,I want that the text boxes on User Control be added on my form(Form1).Is it possible to write such code???
Thank you.
CanI
|
|
|
|
|
|
hey guys.. i have a problem..actually i saw many document about it and i applied on my project but i couldnt solve it..i want to transfer datas btw two forms..for example i open Form2 with a button in Form1
and i want to get the text of the textbox in Form2 as a text of textbox in Form1
to do that i wrote that codes below but still i have nothing
here i opened Form2
private void btnRehber_Click(object sender, EventArgs e)
{
Form2 rhbForm = new Form2();
rhbForm.txtYetkili_isim.Text = txtYetkili_adi.Text;
rhbForm.ShowDialog();
}
and here i filled the textboxes in Form2 and submit the values to the textboxes in Form1
private void btnEkle_Click(object sender, EventArgs e)
{
frmFirma = new Form1();
frmFirma.txtGsm1.Text = txtGsm1.Text;
frmFirma.txtGsm2.Text = txtGsm2.Text;
frmFirma.txtNumara.Text = txtNumara.Text;
}
do i make something wrong ? or is there another way ?
thanks guys for help
|
|
|
|
|
In Form1
public partial class Form1: Form
{
internal static string textboxdata = string.Emtpy;
public Form1()
{
InitializeComponent();
}
private void btnEkle_Click(object sender, EventArgs e)
{
textboxdata = txtGsm1.Text ;
}
}
in Form2 call this way
txtGsm1.Text = Form1.textboxdata ;
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Why suggest a static solution? Do you really think that is a good idea? If so, then perhaps you ought to re-read your C# books / lecture notes and brush up on basic OOP.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Look at your code.
See that keyword on the first line of each method?
The new keyword?
Now, what do you think that does?
1) Create a totally new variable, unconnected to any previous versions.
or
2) Access the correct old version of the variable that you had kicking around somewhere else in your program, but not to worry, the compiler will sort out which one your mean to use when it gets to it.
Now, do you see what is wrong?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
yeah i got what u mean..but what should i do instead of that ?
|
|
|
|
|
Use the existing instance.
private void btnRehber_Click(object sender, EventArgs e)
{
Form2 rhbForm = new Form2();
rhbForm.txtYetkili_isim.Text = txtYetkili_adi.Text;
rhbForm.ShowDialog();
txtGsm1.Text = rhbForm.txtGsm1.Text;
txtGsm2.Text = rhbForm.txtGsm2.Text;
txtNumara.Text = rhbForm.txtNumara.Text;
}
Except that won't work as it is because the TextBoxes are (correctly) private to Form2. So instead add them as properties to Form2:
public class Form2 : Form
{
...
public string Gsm1
{
get { return txtGsm1.Text; }
}
...
} Reapeat for Gsm2 and Numara.
Then access Gsm1 in Form1:
private void btnRehber_Click(object sender, EventArgs e)
{
Form2 rhbForm = new Form2();
rhbForm.txtYetkili_isim.Text = txtYetkili_adi.Text;
rhbForm.ShowDialog();
txtGsm1.Text = rhbForm.Gsm1;
txtGsm2.Text = rhbForm.Gsm2;
txtNumara.Text = rhbForm.Numara;
}
It would also be a good idea to make "yetkili" a property as well, this time with a setter as well as a getter.
The idea is that Form1 does not need to know how Form2 works - just that it can get Gsm data for it.
You can then change the internals of Form2 as much as you like, without having to alter Form1
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
thanks man
i did as i wished with your help and codes
really thank u so much )
|
|
|
|
|
It always amazes me that people try to write the most tortuous logic to communicate between two disparate items in an application when there are mechanisms built into the framework that allow you to do this with ease. Consider the problem if you want to do this with a modeless form; you want to one form to be able to respond to something that happened in another form; can you think of a mechanism that allows you to communicate in this fashion? I am, of course, talking about using events here.
Now, in your case, there is an even simpler way to achieve this. When you create an instance of Form2 (that's not a good name by the way, your naming convention should always indicate the intent of the item you are naming), you then display it using ShowDialog. This means that processing in Form1 halts until Form2 returns control to it - this, of course, means that you have access to the properties and methods inside Form2 until you Dispose of it. What you should do, in Form2, is create public properties that expose the values inside the textboxes and, once control has been returned to Form1, you should then take the values from it. Here's one way to code it:
private void btnRehber_Click(object sender, EventArgs e)
{
using (Form2 rhbForm = new Form2())
{
rhbForm.txtYetkili_isim.Text = txtYetkili_adi.Text;
if (rhbForm.ShowDialog() == DialogResult.OK)
{
txtGsm1.Text = rhbForm.Gsm1;
txtGsm2.Text = rhbForm.Gsm2;
frmFirma.txtNumara.Text = rhbForm.Numara;
}
}
} Then, in Form2, I'd create Gsm1, Gsm2 and Numara as public (or internal) readonly properties which simply wrap access to the relevant textboxes.
|
|
|
|
|
hey friend i did changed my form names as u suggested... thanks for your suggestion..
|
|
|
|
|
|
Got to agree with Pete here. Simple, elegant solutions will always work better than convoluted logic.
|
|
|
|
|
I agree this is the proper way of communicating between 2 forms.
I would also add that you could overload the constructor of the form to pass in a value.
And, you only need to dispose a form if you use ShowDialog[^].
"Make everything as simple as possible, but not simpler." - Albert Einstein Jason Henderson
|
|
|
|
|
hi... instead of using "txtGsm1.Text" better u declare a property in form2 . Then using that property u can do this.
|
|
|
|
|
i have a *.dll file contains a resource file, i want to add an new entry to the resource , so i get the resource file and add the entry. and using resgen created the *.resources file. then using al.exe tried to embed it to the dll, but then the dll is not loaded , it says the dll is corrupted.
al /t:lib /embed:s.resx,my.S.resx /culture:en /out:my.S.Resources.dll
any idea why this happens.
i used this article..NET - Localization using Resource file[^]
thanx in advance
|
|
|
|
|
Please understand, I'm asking this seriously, not to be a prick...
Why would you be creating all this by command line. You could use the Studio Express IDE to create everything you need and still compile the project from the command line. Am I wrong on this, or just confused?
|
|
|
|
|
Hi All,
I have an interesting issue writing strings to the user settings, i.e. [project].Properties.Settings.Default.[property]. Everything goes smoothly unless I try to write a single space as a string. It appears in the file as:
<setting name="someString" serializeAs="String">
<value>
</value>
</setting>
On the next load, it reads as a few unprintable chars and a lot of spaces. But other strings work fine. I'm not quite sure what I have wrong since it works with other strings
Any help is appreciated, thanks!
-Chris
|
|
|
|
|
If you have trim white space turned on in your xml reader, it will read the <value> as null/empty. Try putting the <value> </value> on the same line with a space in between them.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|