|
Hi All...can any1 assist,
im trying to pass values from a datagrid in a popup window to my main page...how can i do this?
living life on the flip side
|
|
|
|
|
If you are truly in a "Popup" (i.e. a modal dialog box), simply overload the ShowDialog method in your "popup" form to call the base implementation of ShowDialog and return the value that you want to have passed back.
private List<t> list;
.
.
.
protected void btnSubmit_Click(object sender, EventArgs e)
{
list = DataGrid.DataSource;
this.close();
}
public List<t> ShowDialog()
{
base.ShowDialog();
return list;
}
</t></t>
Have the "OK" button (or whatever flow control you have in place) set the variable you wish to return and close the form.
"I need build Skynet. Plz send code"
|
|
|
|
|
Hi Alaric...im actually using window.open and inside the window is my page...i want the datagrid values to be sent from this page to my main form
living life on the flip side
|
|
|
|
|
Use delegates. There's plenty of examples here and on the internet.
Here's a very simple example to get you started.
Create a Windows Forms Application and call it DelegateExample.
You'll already have Form1. Add another form and call it Form2 then add a TextBox to it called textBox1.
Change all the code in Form1.cs to this:
using System;
using System.Windows.Forms;
namespace DelegateExample
{
public delegate void UpdateText(string text);
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.SendText = new UpdateText(Update);
frm2.Show();
}
private void Update(string text)
{
Text = text;
}
}
}
Change all the code in Form2.cs to this:
using System;
using System.Windows.Forms;
namespace DelegateExample
{
public partial class Form2 : Form
{
public UpdateText SendText;
public Form2()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
SendText(textBox1.Text);
}
}
}
When you run this - type in the TextBox on Form2 and the Text in the title bar of Form1 will change as you type.
Study the code so you understand what it's doing then you can use this principal in your situation with very little modification.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi Davey...thnx for the reply,,,ill try and see what happens...thnx again
living life on the flip side
|
|
|
|
|
Hi,
it's my first question in this site and I don't know if this one is the right forum.
I've downloaded a C# project from Desktop Development -> Progress Bar called ProgressCircle written by Utezduyar.
I extracted the zip file and I loaded in Visual Studio.
I run...
In instruction Initialize Components (the first instruction of the code) program stops and errors says "Impossible to load file or assembly 'ProgressCircle, Version=...., PublicKeyToken=....'. Impossible to warrant the authorization. (Exception HRESULT: 0x80131417).
In ProgressCircle project there is a key.snk file maybe the project is protected.
I have no idea.
Thanks in advance,
Mauro
|
|
|
|
|
Hi Mauro,
If it's a network share the .NET Framework has all sorts of concerns regarding security. Your best bet is to build then app locally, rather than from a share.
For more information on this, please refer to the below mentioned link:
http://blogs.msdn.com/shawnfa/archive/2004/12/06/276066.aspx
http://forums.msdn.microsoft.com/en-US/netfxbcl/thread/8af927ca-2713-4213-94de-f8b3f2c4364e/
You may also check the Trust Level for the framework. I would suggest you to sign/strong name your assembly to run trusted over the network.
Hope this helps.
John Adams
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Hi,
I found many ways to get the host from url but i need the domain only.
for example - if the url is http://www.abc.com
uri.host = www.abc.com but the domain is abc.com (www is one example)
so, how do i get the domain and not the host?
Thanks,
dana Tov
|
|
|
|
|
.NET has a Uri class, right. Use it.
|
|
|
|
|
as i said in the question the Uri returns the host which is not
identical to domain.
dana Tov
|
|
|
|
|
if (!Url.Contains("://"))
Url = "http://" + Url;
string LstrDomain = Uri(Url).Host;
this should help
|
|
|
|
|
Hi, pros. How to detect a mouse hit on image on the form.
Image have transparent color.
with respect.
What doesn't kill us makes us stronger
modified on Monday, August 4, 2008 11:35 AM
|
|
|
|
|
If the image is in a picture box - just implement the Click() method of the picture box.
dana Tov
|
|
|
|
|
No, It's stand alone image. I know what you mean, but if I will do so there would be another problems, such as how to make PictureBox with transparent color.
What doesn't kill us makes us stronger
|
|
|
|
|
...and i would have many images in pictureBox which would complicate on what of the one I just clicked...
What doesn't kill us makes us stronger
|
|
|
|
|
|
what do u mean by a stand alone image ?
Vikas Amin
UNITED STATES STEEL CORPORATION
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
mean that it alone in picture box by itself.
What doesn't kill us makes us stronger
|
|
|
|
|
|
Hi guys,
Some time ago I've found a very nice (there are probobly more of them) tutorial about developing application for Windows Vista. The article was talking about Vista security model and why it is important to specify application security level using mt.exe tool. Can anybody point me to a similar article?
thanks a lot!
zilo
|
|
|
|
|
Hi Zilo,
Please refer to the below mentioned links for information on creating applications for Windows Vista:
Link 1[^]
Link 2[^]
Link 3[^]
Link 4[^]
I hope this would be helpful.
John Adams
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Thanks John,
You have partly answered my needs, however I was more searching for an article saying why it is important to do it than the actual procedure.
although this is helpful as well, thanks a lot !
zilo
|
|
|
|
|
Hi,
I have a generally question that bother me.
Let me explain it with an example, so that you understand the question.
Let's say we have simple TcpSerer-class which a ConnectionList and looks like this
public class TcpServer {
public List<tcpclient> ConnectionList { get; }
public void start () { }
public void stop () { }
private void client_Connected ( TcpClient client ) {
ConnectionList.Add( client );
}
private void client_Disconnected ( TcpClient client ) {
ConnectionList.Remove( client );
}
}</tcpclient> So, as you can see, this class is not thread-safe.
Because an exception will thrown when i enumerate the ConnectionList
while some Client connect or disconnect.
Thats why i need an object to provide a possibility to lock the ConnectionList
while i enumerate it. OK so far so good.
Now i thought just take the SyncRoot-Property from the ICollection Interface implementation.
But someone told me, i should not use that Object for synchronization with the list.
Because the SyncRoot-Property was a mistake from Microsoft and decoy the developers
to use it without thinking about synchronization.
But the same one told me, that there is no differenc between the object from the SyncRoot-Property
and the object i could provide with a derivation of the List<T>.
Thats why my questions:
Q#1 - Is it true that the SyncRoot-Property was a mistake from Microsoft and shoundnt be used for synchronization. ?
Q#2 - If Q#1 is true then - Why ?
Q#3 - What its the recommended pattern to lock / synchronize any collection.
Thanks in advance.
P.S.: I asked this question already in the msdn-forum but it doesn't satisfy me.
Link: http://forums.msdn.microsoft.com/en-US/netfxbcl/thread/3d760576-7cd2-44d5-936e-969ff5213648/[^]
|
|
|
|
|
A#1) Yes, SyncRoot was a bit of a balls up from someone at MS.
A#2) http://msdn.microsoft.com/en-us/magazine/cc188793.aspx[^]. Basically, IIRC it all boils down to the fact that your lock object should really be private.
A#3) Create a private object and use that.
private Object _lockObject = new Object();
.
.
.
lock(_lockObject)
{
...
}
In theory, if your writing a class to wrap a ICollection object, and if that object is contained privately within your class, and you never expose it directly, then your probably OK to use the SyncRoot object, as it will be private. I'm not totally sure on this though.
Simon
|
|
|
|
|
thank you for the good answer =)
But in the case of the TcpServerClass....I have two possiblilities
P#1 - I provide a lock-object with a collection to synchronize with it ( SyncRoot - )
or
P#2 - I provide a lock-object from the class which wrap the collection ( TcpServer.SyncLock).
But for P#2 i would have to do this everytime i use a collection whereat for the P#1 the lock-object would just come with the collection.
I understand you when you say... lock object should really be private ...but in a development, you should know what you are doing.
So, thats why it is not really necessary, i think
|
|
|
|