|
The first one is pretty simple. Somewhere in your Form1 code you will have something like this:
Form2 form2 = new Form2();
form2.Show(); Just insert
form2.Location = this.Location;
in between.
The second, you will need to create a setting in your project's properties of type System.Drawing.Point . On each Move event (you'll need to subscribe to the event) handling method in Form1, set your setting:
Properties.Settings.Default.YourSettingName = this.Location; and after the InitializeComponent call in Form2, retrieve the setting:
this.Location = Properties.Settings.Default.YourSettingName;
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi Dave,
I cannot believe how simple this solution really is - thank you so much.
I am still getting to terms with the jargon and so on, I was so close!
private void btnOpenForm2_Click_1(object sender, EventArgs e)
{
if (form2 == null || form2.IsDisposed)
{
form2 = new Form2();
form2.Location = this.Location; < ----- I just had to add this
this.Visible = false;
form2.Show();
}
else
{
MessageBox.Show("form2 already open,showing");
form2.Focus();
}
}
I also had to change form2's start position within the code for form2, to
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
Thanks so much again for the help, I really appreciate it!
|
|
|
|
|
Paulo Toureiro wrote: I also had to change form2's start position within the code
That can be done from the designer instead so it's serialized into the Form2.Designer.cs file automatically.
Paulo Toureiro wrote: Thanks so much again
No problem
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I want to know how to do that. I can use foreach and for loop, but I prefer to use the array class.
Assume I have my array like
int[] arrayData = { 1, 3, 5, 0, 6 };
By using .All generic method, it is possible to do something like that to determine if all elements are zero
arrayData.All
So how can I use the .All to determine if all elements in the array is 0
|
|
|
|
|
The MSDN has samples, but basically you write a predicate method that returns what you want to return. For example, a search method would involve you writing the code that checks each element. Under the hood, it's not much different at the end of the day, the code that runs will use for each to check each element.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
arrayData.All(item => item == 0);
|
|
|
|
|
How do you declare item in this case?
|
|
|
|
|
item is an inline-declared parameter. You shouldn't have to explicitly declare it anywhere. Enumerable.All should be able to determine the type of the parameter at compile-time.
Note: I'm not in front of my compiler right now, but it's possible (?) that you may have to explicitly provide the parameter with a type. In that case, I believe the syntax would be:
arrayData.All((int item) => item == 0); (disclaimer: this is all coming from memory, so I might not be spot-on )
|
|
|
|
|
It seems to work fine now
|
|
|
|
|
Your method works fine, but it looks like it is not possible to check if all elements equal 0 in a 2D array. I couldn't find a way to do that for a 2D array as I did for a 1D. Is there a way to check if all elements is 0 in a 2D array?
|
|
|
|
|
Hi all,
I am using ASP.NET 2.0 in C#. I have a database full of products. Depending on the product series depends on the specs that I want to show. I have a gridview to show the different models of a series. Each product series has a different set of specs. I would like to have a gridview to show the specs of a number of models in a series and if you click on a different series you might get a different specs.
Down to it, I want to know how to hide columns that are null or empty when a query is done. And if the query has data in the columns to show them. This way only the columns that have data in them are shown.
Any suggestions?
edcorusa
|
|
|
|
|
string sql = "Select Count(*) From TABLE_NAME";
Run this query and catch return value using ExecuteScalar(). If return value equal 0 so GridView.Datasource = null;
Another way; if using DataSet or DataTable use Row.Count property. If Row.Count equal 0 so GridView.Datasource = null;
|
|
|
|
|
I am sorry, but that does not seem to do what I am after.
Lets say I have three columns, titled COL1, COL2 and COL3. When I do a query and rows of data are return and there is no data in COL3 I wish to hide it.
|
|
|
|
|
DataTable myDt = ....(write necessary code)
DataGridView1.DataSource = SupressEmptyColumns(myDt);
private DataTable SupressEmptyColumns(DataTable dtSource)
{
System.Collections.ArrayList columnsToRemove = new System.Collections.ArrayList();
foreach(DataColumn dc in dtSource.Columns)
{
bool colEmpty = true;
foreach(DataRow dr in dtSource.Rows)
{
if (SqlConvert.ToString(dr[dc.ColumnName]) != string.Empty)
{
colEmpty = false;
}
}
if (colEmpty == true)
{
columnsToRemove.Add(dc.ColumnName);
}
}
foreach(string columnName in columnsToRemove)
{
dtSource.Columns.Remove(columnName);
}
return dtSource;
}
|
|
|
|
|
I have been building a GUI that interfaces with 3 services via remoted interfaces. I'm using GenuineChannels (http://www.genuinechannels.com) broadcast engine as the framework for event based communication between services & the GUI. Since you can only register one remoted object per AppDomain (I hope that statement is correct), I've had to create a seperate AppDomain for each UserControl in the GUI so more than one remoted object can be registered. Each UserControl contains a TreeView that needs to be updated via the broadcast engine, or remoted events. Everything appears to be working just as I had hoped, but here is my problem. I've tried using different types of delegates at different scopes within the code & also tried refactoring my code, but I cannot seem to come up with a way to update the TreeView instance within the UserControl from a remoted object in a seperate AppDomain. Here's most of the code from the classes involved. Unimportant peices have been removed.
namespace Console
{
public partial class ControlDelegate : UserControl
{
public ControlDelegate()
{
InitializeComponent();
// Create appdomainsetup information for the new appdomain.
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = System.Environment.CurrentDirectory;
setup.ApplicationName = ("Delegate-" + AppDomain.CurrentDomain.FriendlyName);
//Create evidence for new appdomain.
Evidence evidence = AppDomain.CurrentDomain.Evidence;
// Create the application domain.
AppDomain domain = AppDomain.CreateDomain(("Delegate-" + AppDomain.CurrentDomain.FriendlyName), evidence, setup);
DelegateMessenger remote = (DelegateMessenger)domain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, Assembly.GetCallingAssembly().GetName().Name + ".DelegateMessenger");
Thread thread = new Thread(new ThreadStart(remote.Construct));
thread.Start();
}
/****************************/
this method must be static to refer to it, which is my problem.
/****************************/
public static void tViewDelegateHeartBeat(Objects.Message message, String nickname)
{
System.Console.WriteLine(message.action);
/****************************/
The line below is all that I need to make project functional.
/****************************/
//tViewDelegate.Nodes.Add(message.action + " " + nickname);
}
}
public class DelegateMessenger : MarshalByRefObject, IDelegateMessenger
{
public static String Nickname = "Delegate-" + Assembly.GetExecutingAssembly().GetName().Name;
public static DelegateMessenger Instance = new DelegateMessenger();
public static IDelegateChat iDelegateChat;
public static IDelegateServer iDelegateServer;
public static Object IDelegateChatLock = new Object();
public void Construct()
{
try
{
// Setup remoting with assembly objects as remote object.
IDictionary props = new Hashtable();
props["name"] = "gtcpd";
props["prefix"] = "gtcpd";
props["priority"] = "100";
props["port"] = "0";
GenuineTcpChannel channel = new GenuineTcpChannel(props, null, null);
ChannelServices.RegisterChannel(channel, false);
WellKnownClientTypeEntry remotetype = new WellKnownClientTypeEntry(typeof(SharedChannels.GenuineTcp.GenuineTcpChannel), "gtcpd://127.0.0.1:48886/DelegateMessenger");
RemotingConfiguration.RegisterWellKnownClientType(remotetype);
// Bind client's receiver.
RemotingServices.Marshal(Instance, "DelegateMessenger");
// Subscribe to the chat event.
lock (IDelegateChatLock)
{
iDelegateServer = (IDelegateServer)Activator.GetObject(typeof(IDelegateChat), "gtcpd://127.0.0.1:48886/DelegateServer");
iDelegateChat = iDelegateServer.JoinDialog(Nickname);
}
}
catch (Exception ex)
{
MessageBox.Show(Environment.NewLine + String.Format("Exception: {0}. Stack trace: {1}.", ex.Message, ex.StackTrace));
}
}
public Object ReceiveMessage(Objects.Message message, String nickname)
{
/*****************************/
this works fine if the receiving function is static, but I
need to refer to an instance method to be able to update
the UserControl TreeView (tViewDelegate).
/*****************************/
AppDomain.CurrentDomain.DoCallBack(delegate { ControlDelegate.tViewDelegateHeartBeat(message, nickname); });
/*****************************/
this works if I register only one remoted object within
the GUI AppDomain, which won't work with my current design
since I need to access several remoted objects from other UserControls.
/*****************************/
// http://blogs.msdn.com/csharpfaq/archive/2004/03/17/91685.aspx
/* if (tViewDelegate.IsHandleCreated)
{
try
{
tViewDelegate.Invoke(new tViewDelegateCallback(this.tViewDelegateHeartBeat), new Object[] { message, nickname });
}
catch (Exception ex)
{
MessageBox.Show(Environment.NewLine + String.Format("Exception: {0}. Stack trace: {1}.", ex.Message, ex.StackTrace));
}
}
*/
return null;
}
public override Object InitializeLifetimeService()
{
return null;
}
}
}
I'm hoping someone sees something silly that I'm doing and can point it out. The project is still in its infancy, so I could refactor everything if need be. Any ideas?
modified on Wednesday, March 11, 2009 3:42 PM
|
|
|
|
|
hi,
i created VSTO 2003 addin for outlook inspector. i want to check the attachment when we open any mail item, i want to know how to check and attachment when we open item from inbox.
here is actually what i want..
when we open any inbox item, inspector region opens, if any attachments is present, upon clicking the addin button which is in inspector region i want that attachment to store in specified location. can any one help me in this. i've created addin in inspector region, i need help form this point. please help me.
Thanks.
Arun.
|
|
|
|
|
Could u explain breafly your question?
|
|
|
|
|
Hi!
I'm learning to work with webservice, and now I have a problem..
I'm using this guide:
http://www.exforsys.com/tutorials/asp.net/creating-and-consuming-xml-web-services-with-csharp.html[^]
When I try to compile my console-application, this message appears:
Error 1 The type or namespace name 'Service1' does not exist in the namespace 'MyClient.MyService' (are you missing an assembly reference?) C:\Documents and Settings\Bryan\Mina dokument\Visual Studio 2008\Webbservice\MyClient\MyClient\Program.cs 15 23 MyClient
Error 2 The type or namespace name 'Service1' does not exist in the namespace 'MyClient.MyService' (are you missing an assembly reference?) C:\Documents and Settings\Bryan\Mina dokument\Visual Studio 2008\Webbservice\MyClient\MyClient\Program.cs 15 56 MyClient
The code for the webservice:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
namespace WebServiceExample
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
The code for my console application:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyClient
{
class Program
{
[STAThread]
static void Main(string[] args)
{
MyService.Service1 service = new MyService.Service1();
string message = service.HelloWorld();
Console.WriteLine(message);
}
}
}
|
|
|
|
|
In the project for your console application, has a reference been added to your web service?
|
|
|
|
|
Have you created a web reference to the service ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hmmm, when I'm adding a reference, I right-click on my projectname in the solutionbox and paste the URL of my service. Is that correct or should I do it on a another way?
|
|
|
|
|
1. Open Visual Studio, create your web service and run it. (Do not stop)
2. Open Visual Studio (new one, not close first), create console application
3. Right click to References folder on the solution explorer.
4. Select "Add Service Reference..."
5. write your web service address (For example: http://localhost/Service.asmx)
6. Discover it.
|
|
|
|
|
While creating the proxy service you have used
MyService.Service1 service = new MyService.Service1();
but the namespace says it is WebServiceExample.
try doing this...
WebServiceExample.Service1 service = new WebServiceExample.Service1()
I think it should solve your problem....
|
|
|
|
|
Hi,
I've been asked to look at creating sale orders on a Microsoft Dynamics Retail Management System (RMS). Unlike CRM, there doesn't seem to be any readily available SDK or API that I can download. Nor does there seem to be a version available through my MSDN subscription or through the Microsoft Action Pack.
Can anyone tell me if it's even possible to do any integration work with Microsoft Dynamics Retail Management System? All I want to do is take an order from a web site and pass its details to MS Dynamics RMS.
You'd think it was easy
I've been onto a few forums including the main Microsoft one, but as soon as anyone asks a similar question, several people jump in and try to sell them their services. I'm a programmer - I just need an API to develop against...
Cheers for looking
|
|
|
|
|
It seems that you already have a hard time understanding that this forum is for C# questions, it does not surprise me that you can't find anything on Dynamics.
Good luck.
|
|
|
|