|
m_els wrote:
Is it possible to have a textbox in a context menu??
Yes, Access does something like this however you will need to write your own subclass of a MenuItem that handles the TextBox .
- Nick Parker My Blog | My Articles
|
|
|
|
|
thanks...but do you know any tutorials or something that describes this??
|
|
|
|
|
How might one go about embedding certain Office features into a C# application? More specifically, I would like to be able to visually paste, resize, and crop images into a control in my application. Are there components I can simply include into my application to accomplish this? If so, can I also put them into an .ASPX page?
Thanks!
|
|
|
|
|
If you customize your toolbox to include the OCW (Office Components for the WEb) you can embed them as ActiveX controls as you would with other ActiveX controls, but you can't just take functionality like paste, resize, and cropping images. That type of implementation is not simply reusable components most often, at least not with Office (Office apps share functionality, but not always in a way you can reuse). Especially with copy/paste and drag/drop that functionality is very specific to an application, as far as what storage mediums and clipboard formats it supports (and .NET exposes only supports a few STGMEDIUM s, excluding TYMED_ISTREAM and TYMED_ISTORAGE ).
You can embed the OCWs into any web page. Remember that ASP.NET describes server-side functionality, hence being called Active Server Pages (.NET). Only minimal client-side script is used to support server-side state.
You could embed OCWs even into pages generated from PHP running in Apache on a linux machine and it wouldn't make a bit of difference. Anything a client views in a browser is downloaded from the server to the client application. That's how HTTP along with most other protocols work.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I have a customer that is getting the following exception when the program attempts to make a simple connection:
Exception: System.Net.Sockets.SocketException
Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Source: System
at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port)
This seems to me that the server isn't running anything on the specified port, however he swears he can telnet to the port on the command prompt.
Here is the exact code that causes this problem.
System.Net.Sockets.TcpClient testConnection =
new System.Net.Sockets.TcpClient ();
testConnection.Connect (smtpHost, smptPort);
testConnection.Close();
I believe he has entered his information incorrectly but he says it has just recently started happening and it worked before without any problems. Could XP SP2 be causing this problem? There is enhanced code that only allows a certain number of connections to be made but I thought it gave a policy violation error instead of the timeout error.
Has anyone experienced anything like this before?
Thanks.
-
Andrew T Finnell
|
|
|
|
|
You should make sure the client - as well as your development team - is updated to the newest .NET Framework Service Packs, available at http://msdn.microsoft.com/netframework/downloads/[^]. Be sure to download the right versions and locales, as well as for the right platform (Windows Server 2003 uses a different installer technology than the rest of the current Windows platforms).
For changes made in Windows XP SP2 that affect developers, read http://support.microsoft.com/default.aspx?pr=WindowsXPsp2Dev[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
How on earth can such a statement be thread safe?
|
|
|
|
|
I'm just trying to force a single-threaded apartment.
Being a safe or non-safe thread is another issue.
Stanley
|
|
|
|
|
Hi Nick,
Still no luck after making the changes you've suggested.
Stanley
|
|
|
|
|
how to i seek for something after i have it in my dataset?
i select record from my sql database and now i want to seek throw the records
thanks
chad
|
|
|
|
|
You can itterate through each row in each table and use the
ItemArray.GetValue
i.e.
Int32 myInt = (Int)myDataSet.Tables[0].Rows[0].ItemArray[0];
But you need to know what data types you are getting from each cell to be able to cast them.
There may be a better way but this is how i have done it in the past.
Kev
|
|
|
|
|
hi code guys!
I have a web browser control in my c# app. Now the following code gives me access to page contents.
////////////
HTMLDocument myDoc= new HTMLDocumentClass(); myDoc = (HTMLDocument) WB.Document;
String var= myDoc.body.InnerText;
//////////
All works fine but this code never goes into the frames. I need to access particular frame’s contents. I have tried different things but never got anything right.
Firstly I need the code to determine how much frames the particular page has.
Then I want to get first frame’s contents.
Thanks
|
|
|
|
|
A document that includes frames links to other documents - one for each frame. You must get the frame count from the top-level document and enumerate through each frame. Also, don't instantiate myDoc - you're getting an instance from WB.Document . There is absolutely no reason to instantiate it and you're just adding memory overhead anyway.
An example follows:
IHTMLDocument2 doc = (IHTMLDocument2)WB.Document;
if (doc != null)
{
int len = doc.frames.length;
if (len > 0)
{
IHTMLWindow2 window = null;
IHTMLDocument2 frameDoc = null;
for (int i=0; i<len; i++)
{
object index = i;
window = (IHTMLWindow2)doc.frames.item(ref index);
if (window != null)
{
frameDoc = window.document;
if (frameDoc != null)
Console.WriteLine(frameDoc.body.innerHTML);
}
}
}
else
Console.WriteLine(doc.body.innerHTML);
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi,
I've got a customized datetime picker that includes a popup modal dialog. I need to make sure the popup stays completely on the users screen so they can close the control (button is at the bottom). Are there any functions available to tell me that it's being clipped?
thanks,
Deanna
|
|
|
|
|
There are several ways of doing this. If you're using a system modal dialog (set TopMost to true on your Form ), you can determine if the PaintEventArgs.ClipRectangle is equal to your client Bounds in your OnPaint override:
protected override void OnPaint(PaintEventArgs e)
{
if (e.ClipRectangle != Bounds) { }
base.OnPaint(e);
} This works because you're a system modal dialog. The only thing hiding it is either another system modal dialog (the likeliness of another is unlikely in most circumstances, especially based on what your dialog is prompting for) or it's outside the screen area.
There's much better ways of doing this, though. You could use properties of the Screen class and methods of the Rectangle struct to determine extents. You could even prevent the dialog from extending past the screen, something we've discussed in the past here (click "Search comments" above).
Yet another way - and most likely more pleasing to users and better regarding usability - is to popup the window directly above or below the DateTimePicker (or whatever you're using), much like the standard DateTimePicker does. This is a common user interface and presents a common user experience, something the Windows UI Guidelines drive. Having a popup window appear distant from the value could be consfusing for some users and annoying for others that get frustrated with having to look all over their screen (I know I would). Just make the popup window borderless and they can't move it. That's much like specifing the WS_POPUP window style for the dialog if you were natively coding such a control.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks Heath. Yes, normally the popup is located right below the main control, but if the main control is too near the bottom of the screen I want it to go up top instead.
|
|
|
|
|
I am trying to do the simplest thing with the Windows Forms .NET DataGrid Control. I want to simply bind a recordset from a SQL statement at runtime. This code shows what I am TRYING to do.
String connStr = "Data Source=(local); database=plandata; User ID=sa; pwd=";<br />
SqlConnection conn = new SqlConnection(connStr);<br />
String st;<br />
st = "select * from relationships";<br />
SqlCommand cmd = new SqlCommand(st,conn);<br />
conn.Open();<br />
<br />
dataGrid1.DataSource = cmd.ExecuteReader();<br />
dataGrid1.DataBind();
Apparently it is not this easy. When I attempt to call DataBind(), I get an error saying I have to use IList or IListSource.
Can someone show me how I do this? I can't find an example anywhere. I need to bind at runtime, not design time.
Thanks!
Mark
|
|
|
|
|
Read the values into a DataTable then set the DataSource to that table.
If you are going to have multiple tables then put them into a DataSet and use the DataSet as the source.
Kev
|
|
|
|
|
Kev,
That sounds good. Thanks.
But will a DataTable hold large tables with dozens of columns and thousands of rows? For instance, SQL Query Analyzer will easily display a huge table with thousands of rows. Will this technique be comparable?
Thanks again!
Mark
|
|
|
|
|
Mark,
I wrote an app for our office that analyses text files each week and puts the result into a dataset which can then be used to update our Data Warehouse. I'm not sure on the limitations but we run the program once a week and it deals with 25,000 +rows each time. This can be output to a datagrid without any problems but i suppose it will depend on the memory / processor in the machine.
Hope that's OK for ya.
Kev
|
|
|
|
|
Hi..
I have a specification sheet which has a horizontal scrool bar..
I would like to know what is the windows notify message sent when i move the horizontal scroll bar. I tried WM_HSCROLL but it was not working for me..
Can any one help me in this reg.
Thanks
Sudhakar
|
|
|
|
|
Make sure WM_HSCROLL and WM_VSCROLL are defined correctly, as in this example:
using System;
using System.Drawing;
using System.Windows.Forms;
class Test : Form
{
static void Main()
{
Application.Run(new Test());
}
Label lbl;
Test()
{
Text = "Sample";
AutoScroll = true;
lbl = new Label();
Controls.Add(lbl);
lbl.Location = new Point(0, 0);
lbl.Size = Size + Size;
lbl.TextAlign = ContentAlignment.MiddleCenter;
}
protected override void OnResize(EventArgs e)
{
lbl.Size = Size + Size;
base.OnResize(e);
}
const int WM_HSCROLL = 0x0114;
const int WM_VSCROLL = 0x0115;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_HSCROLL)
{
lbl.Text = string.Format("HPos: {0}", HIWORD((int)m.WParam));
}
if (m.Msg == WM_VSCROLL)
{
lbl.Text = string.Format("VPos: {0}", HIWORD((int)m.WParam));
}
base.WndProc(ref m);
}
int HIWORD(int dword)
{
return dword >> 16;
}
} (Scroll to the center and watch the values change)
You can also use the AutoScrollPosition for a ScrollableControl derivative, which includes (but is not limited to) Panel , UserControl , and Form .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I've been trying to start an application running in a minimsed mode and thought i could use ProcessStartInfo to do this. I created a new ProcessStartInfo instance.
ProcessStartInfo startInfo = new ProcessStartInfo("calc");
and set
startInfo.WindowStyle = ProcessWindowStyle.Minimized .
To run the application i used the line
Process.Start(startInfo);
After reading the help file on the ProcessStartInfo class i assumed this would start the application, calc, minimised to the task bar but it doesn't. It starts calc fine but it's just in a normal window.
Any suggestions?
Kev
|
|
|
|
|
This doesn't work with every application. Some application may retain window position and other state information written to storage when closed and reapply that state information when opened. This is often the case.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for the tip, just tried it with a command window app and it minimizes the window fine. Is there any way to override the loaded state information? It doesn't matter that much because it's an in house application but it would be nice.
Cheers
Kev
|
|
|
|