|
Hmm. Something to think about I guess
Thanks.
|
|
|
|
|
Take a look at the System.Environment class, there's a property or function there that will do this directly. Can't remember what it's called though.
The Welsh will always support two teams: The Welsh, and anyone playing England
|
|
|
|
|
Yeah, I saw that, but I couldn't get it to work for me. I'm guessing it's because my service is running as a LocalSystem, and those settings only pull information when your program is running under a user account.
|
|
|
|
|
I'm trying to position a Windows MDI child form in a specific place in relation to other children. I'm setting the Location property prior to calling .Show(). Sometimes (every other time) it works. Sometimes it does not - the form is not positioned where I just said it should go.
Does anyone know how to make it work?
Jennifer
|
|
|
|
|
Have you tried changing the location in response to an event like "Form.Shown"?
|
|
|
|
|
I tried it, but it doesn't work quite right.
I had to do a funky work-around though, because the child form doesn't know where it's supposed to go - the parent is the only one aware of the other forms I'm trying to arrange. So the child notified the parent when it was shown and the parent repositioned the form. The problem is, the user sees the form move.
Thanks for the suggestion though. The next one did work, by the way. (Setting the start position to manual.)
|
|
|
|
|
With MDI I'm not sure, but have you tried changing the child form's StartPosition property to Manual?
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
Thanks! That did the trick. I thought I had tried that already, but I've done so many different things trying to make this work, that perhaps it was a different version of the form, or a different drawing mechanism. Regardless, it works like a champ now. Thanks again!
|
|
|
|
|
Hi! I am here again. I am not sure whether I should post this message at C# or ASP.NET. Anyway, I have a datagrid binded to sqlquery data. I want to do a report generation, when the user click the view report button, the datagrid will be transferedto another webform in C#.
I tried using Server.transfer(2ndpage); but it did not work.
thanks in advance. Much appreciated.
|
|
|
|
|
blurMember wrote: Server.transfer(2ndpage); but it did not work.
That is ASP.NET and don't tell them "it did not work" you need to be specific.
|
|
|
|
|
I will post the specific reply at ASP.NET. Thanks.
thanks in advance. Much appreciated.
|
|
|
|
|
Hi. I am currently doing a project using vb.net and c#. Is it possible to temporary remove certain collection item of dropdownlist?
is this the solution:
dropdownlist1.items.remove(items)?
what does (items) refers to?
thanks in advance. Much appreciated.
-- modified at 13:32 Wednesday 5th July, 2006
|
|
|
|
|
Hi all,
i made a simple proxyserver which can display basic HTML page at client site, but i have no idea why the image part of webpage always gone!!
following is my simple code which accept the request from client site, then reponse.
<br />
int port = 8080;<br />
Socket proxyServer = new Socket(AddressFamily.InterNetwork,<br />
SocketType.Stream,ProtocolType.Tcp); <br />
proxyServer.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 5000); <br />
<br />
proxyServer.Bind( new IPEndPoint(GetHostIP(), port) );<br />
proxyServer.Listen( port );<br />
<br />
Console.WriteLine("ProxyServer started at port " + port);<br />
Console.WriteLine("ProxyServer ready for accepting incoming connections..."); <br />
<br />
while(true)<br />
{<br />
Socket clientConnect = proxyServer.Accept(); <br />
NetworkStream clientStream = new NetworkStream( clientConnect, true ); <br />
<br />
HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create("http://www.google.co.uk/intl/en_uk/images/logo.gif");<br />
loHttp.Timeout = 10000; <br />
HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse(); <br />
<br />
System.IO.StreamReader loResponseStream =<br />
new System.IO.StreamReader(loWebResponse.GetResponseStream()<br />
, System.Text.Encoding.UTF8);<br />
<br />
<br />
Byte[] buf = System.Text.Encoding.UTF8.GetBytes( loResponseStream.ReadToEnd() );<br />
<br />
loWebResponse.Close();<br />
loResponseStream.Close();<br />
<br />
<br />
clientStream.Write(buf, 0, buf.Length);<br />
clientStream.Flush();<br />
clientStream.Close();<br />
}<br />
plz help me out~~
many thanks!
|
|
|
|
|
Bluebamboo wrote: plz help me out
Isolate the code that downloads the GIF file and unit test it.
|
|
|
|
|
Hi mike,
Thanks for your reply,but i am not quite clear about what you said, do you mean i should save my code part in GIF format file then upload it? GIF? a picture?
|
|
|
|
|
The part that uses a HttpWebRequest to download the image file resulting in a byte array containing the image. That should be isolated and unit tested. The unit test could save the byte array to a disk file that can be verified to be correct. None of that has anything to do with your "proxyServer" and sending the byte array to the client socket. That is why it can and should be "isolated". Take some time to read about software design principles.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
How to count total properties in a class.
suneet
|
|
|
|
|
typeof(SomeClass).GetProperties().Length
:josh:
My WPF Blog[^]
|
|
|
|
|
Thanks Josh..........for your help...this worked.....
suneet
|
|
|
|
|
Hi all. I need to call a method of my .NET COM-object from Word. How can I do it?
I've written an object, checked all these "COMVisible", "register for COM Interop" etc.
In Word I can see a reference to it. After adding the reference I write the script:
Dim Ob As Object
Set Ob = CreateObject("ClassLibrary1.FOO")
On CreateObject line I get: "Run time error 429. ActiveX component can't create object".
Or if I write so:
Dim Ob As Object
Set Ob = New Classlibrary1.FOO
I get: "Run-time error -2147024894 (80070002). File or assembly Classlibrary1, or one of it's dependencies was not found".
Which dependencies? It's just a test project! Here is the source code:
using System;
using System.Runtime.InteropServices;
namespace Chapter_Code
{
[GuidAttribute("1C6CD700-A37B-4295-9CC9-D7392FDD425D")]
public interface IFoo
{
string PrintMe();
int ShowState();
void SetState(int newState);
}
[GuidAttribute("C09E2DD6-03EE-4fef-BB84-05D3422DD3D9")]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ProgIdAttribute("Chapter_Code.Foo")]
public class Foo : IFoo
{
public Foo() { }
private int state = 100;
public string PrintMe()
{
return ("TEST SUCCESS");
}
public int ShowState()
{
return (state);
}
public void SetState(int newState)
{
state = newState;
}
}
}
Your help is much appreciated!
Knows where to go everyday.
|
|
|
|
|
Did you use regsvr32 on the com object?
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
it's .NET COM object, so I used "regasm CodeLibrary1.dll /codebase".
There were some little mistakes in namespace and ProgID in my code. So here is the final variant:
using System;
using System.Runtime.InteropServices;
namespace ClassLibrary1
{
[GuidAttribute("1C6CD700-A37B-4295-9CC9-D7392FDD425D"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IFoo
{
[DispId(1)]
string PrintMe();
[DispId(2)]
int ShowState();
[DispId(3)]
void SetState(int newState);
}
[GuidAttribute("C09E2DD6-03EE-4fef-BB84-05D3422DD3D9"),
ClassInterfaceAttribute(ClassInterfaceType.None)]
[ProgIdAttribute("ClassLibrary1.Foo")]
public class Foo : IFoo
{
public Foo() { }
private int state = 100;
public string PrintMe()
{
return ("TEST SUCCESS");
}
public int ShowState()
{
return (state);
}
public void SetState(int newState)
{
state = newState;
}
}
}
Now using CreateObject or New gets the same error: "Run-time error -2147024894 (80070002). File or assembly Classlibrary1, or one of it's dependencies was not found".
|
|
|
|
|
Hi,
I wanna to format any date like SQL Date without changing Regional setting? Where I wanna 2 send a date in a field in sql-server of type date but it changes automatically 2 system format, so I must change regional setting, But I dont like this way
Can Anyone Help me, with a solution?
23DoorsDown
Regards,
Hisham Galal <me4webby@yahoo.com>
|
|
|
|
|
The following function will format a datetime like the old vb dateformat and return a varchar. I use this all the time to format dates in my applications.
/****** Object: UserDefinedFunction [dbo].[udf_FormatDate] Script Date: 07/05/2006 11:11:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create FUNCTION [dbo].[udf_FormatDate] (@date datetime, @format varchar(50))
RETURNS VARCHAR(50) AS
BEGIN
-------------------------------------------------------------------------------------
--
-- Name: FormatDate
--
-- Purpose: Mimics the VB Format routine for dates
--
-- Parameters:
-- @date - Date, Date to be formatted
-- @format - String, Template to format the date to
--
-- Returns: String, Date formatted to user requested template
--
-- Notes:
-- 1. Time information is not accounted for in this routine
--
-- 2. @format accepts the following values for each section of the date.
-- Day
-- dddd - Full Day Name
-- ddd - Abbreviated Day Name
-- dd - Zero Padded Day Number
-- d - Day Number
--
-- Month
-- mmmm - Full Month Name
-- mmm - Abbreviated Month Name
-- mm - Zero Padded Month Number
-- m - Month Number
--
-- Year
-- yyyy - Full 4 digit year
-- yy - 2 digit year
--
-- 3. Any unexpected characters will be returned in the string
--
-- 4. Assumes database was set up with case-insensitive collation
--
-- Example Usage:
-- All examples use the following date 2003-07-13 00:00:00
--
-- 'dddd, mmmm dd, yyyy' --> Sunday, July 13, 2003
-- 'mmddyyyy' --> 07132003
-- 'm-d-yy' --> 7-13-03
-- 'mm/dd/yyyy' --> 07/13/2003
--
-------------------------------------------------------------------------------------
DECLARE @pos AS INTEGER
DECLARE @char AS VARCHAR(1)
--
-- Replace Year
--
SET @pos = CHARINDEX('yyyy', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 4, DATENAME(yyyy, @date))
--PRINT @format
SET @pos = CHARINDEX('yyyy', @format)
END
SET @pos = CHARINDEX('yy', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 2, RIGHT(DATENAME(yyyy, @date) ,2))
--PRINT @format
SET @pos = CHARINDEX('yy', @format)
END
--
-- Replace Month
--
SET @pos = CHARINDEX('mmmm', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 4, DATENAME(month, @date))
--PRINT @format
SET @pos = CHARINDEX('mmmm', @format)
END
SET @pos = CHARINDEX('mmm', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 3, LEFT(DATENAME(month, @date), 3))
--PRINT @format
SET @pos = CHARINDEX('mmm', @format)
END
SET @pos = CHARINDEX('mm', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 2, RIGHT(('0' + CAST(DATEPART(month, @date) AS VARCHAR(2))), 2))
--PRINT @format
SET @pos = CHARINDEX('mm', @format)
END
SET @pos = CHARINDEX('m', @format)
WHILE @pos > 0
BEGIN
-- account for MArch and deceMBer
SET @char = SUBSTRING(@format, @pos + 1, 1)
IF (@char <> 'a') AND (@char <> 'b')
BEGIN
SET @format = STUFF(@format, @pos, 1, CAST(DATEPART(month, @date) AS VARCHAR(2)))
--PRINT @format
SET @pos = CHARINDEX('m', @format)
END
ELSE
BEGIN
SET @pos = CHARINDEX('m', @format, @pos + 1)
END
END
--
-- Replace Day
--
SET @pos = CHARINDEX('dddd', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 4, DATENAME(weekday, @date))
--PRINT @format
SET @pos = CHARINDEX('dddd', @format)
END
SET @pos = CHARINDEX('ddd', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 3, LEFT(DATENAME(weekday, @date), 3))
--PRINT @format
SET @pos = CHARINDEX('ddd', @format)
END
SET @pos = CHARINDEX('dd', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 2, RIGHT(('0' + DATENAME(day, @date)), 2))
--PRINT @format
SET @pos = CHARINDEX('dd', @format)
END
SET @pos = CHARINDEX('d', @format)
WHILE @pos > 0
BEGIN
-- account for DEcember, sunDAy --> saturDAy, weDNesday
SET @char = SUBSTRING(@format, @pos + 1, 1)
IF (@char <> 'e') AND (@char <> 'a') AND (@char <> 'n')
BEGIN
SET @format = STUFF(@format, @pos, 1, CAST(DATEPART(day, @date) AS VARCHAR(2)))
--PRINT @format
SET @pos = CHARINDEX('d', @format)
END
ELSE
BEGIN
SET @pos = CHARINDEX('d', @format, @pos + 1)
END
END
IF @format = '//' BEGIN
SET @format = ''
END
RETURN @format
END
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
|