|
The control should capture the onclick events by itself. Where are you putting the control? Is it on a webform or winform? When I create a user control in a winform and click the buttons it responds as it should. What are you trying to do exactly?
-------------------------------------
Do not do what has already been done.
|
|
|
|
|
"Where are you putting the control?"
I drag and drop the control from "MyUserControls" on the toolbox to 'form1' or whatever.
"Is it on a webform or winform?"
It's a winform.
"What are you trying to do exactly?"
All I'm trying to do is make 'form1' respond to a click of a button on the control I added to the form.
So for instance....when you click the "personnel" button a label's text on 'form1' changes.
I'm trying to get a handle on where you put things.
Thank you!
|
|
|
|
|
If the button was in a user control so you must handle it's click event in the code of the user control itself.
|
|
|
|
|
Ok here's the statement I was missing....
the event handler I needed to add in the form was not just to the control, but to the control within the control.......I know it's a headache. Here's the statement
this.left_navigation1.linkLabel1.Click += new EventHandler(linkLabel1_Click);
Thats all I was missing....
Thanks all for you response!
|
|
|
|
|
The button exposes a Click event that you can subscribe to. From within the event handler for click, you can set the label's text to whatever you want. The code will look like
public class MainForm : Form
{
private Button button = new Button("Hai");
private Label label = new Label();
private void InitializeComponent()
{
button.Click += new ClickHandler(MainForm_buttonClick);
}
private void MainForm_ButtonClick(object sender, EventArgs e)
{
label.Text = "Bye";
}
}
Note that you don't need to write all the event wireup code, VS.NET does it for you. You only need to write code to set the label's text.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello. I'd like to write a CAB extracting/packing application, and am looking for MSZIP/LZX implementations (no matter what programming language it/they is/are in) or format specifications.
Thank you, and regards,
Stan
|
|
|
|
|
Good day all.
I have a two column ListView. I am having problems getting my ListView to display text in the 2nd column after the first row. The first row works fine for both columns 1 and 2. When I write data the second time. Row 2 column 1 writes the data but column 2 does not.
I am trying to use Listview.Items[0].Add( "xxxx" ); to update the 2nd column.
Thank you in advacne for your assistance.
|
|
|
|
|
try ListView.Items[n].SubItems.Add("xxxx")
|
|
|
|
|
Hi,
I am new in devloping applications for communication between devices.
How can i do serial port communication on .NET platform using C#(.NET Framework 1.1).
Please, let me know some good articles/books to learn "how to communicate to devices".
Thanks for some help.
Subrahmanyam.
|
|
|
|
|
There are a number of articles here on CodeProject, use the search article above with the word "Serial".
Here's one to get you started: http://www.codeproject.com/dotnet/DotNetComPorts.asp[^]
Gary
Marc Clifton: "In other words, VB is like a bad parent. It can really screw up your childhood."
|
|
|
|
|
Hi
Could anybody offer advice as to how to periodically search all open windows for a window with a known text property then programmatically step through its controls entering stuff and finally firing a button click event.
Thanks
PL
|
|
|
|
|
I use the following code to do what you want to do. I have changed some names to protect the innocent, so where you values inside <>, just change it to reflect what you need.
Usage: Just copy and paste into a class file.
Good Luck!
<br />
using System;<br />
using System.Text;<br />
using System.Runtime.InteropServices;<br />
using System.Diagnostics;<br />
<br />
namespace APPLoginWindow<br />
{<br />
public class APPLogin<br />
{<br />
<br />
private object data;<br />
<br />
#region Contructor, dispose, main<br />
public APPLogin()<br />
{<br />
getAPPLogin();<br />
}<br />
#endregion<br />
<br />
#region win32 imports<br />
public delegate bool EnumWindowsCallback(int hwnd, int lParam);<br />
public delegate bool EnumThreadProc(IntPtr hWnd, IntPtr lParam);<br />
<br />
[DllImport("User32.dll")] public static extern int GetWindowText(int hwnd,StringBuilder lpString, uint bufferSize);<br />
<br />
[DllImport("User32.dll")] public static extern int EnumWindows (EnumWindowsCallback callback, int lParam);<br />
[DllImport("User32.dll")] public static extern int EnumChildWindows (int hWndParent, EnumWindowsCallback callback, int lParam);<br />
[DllImport("User32.dll")] public static extern bool EnumThreadWindows (uint threadId, EnumThreadProc pfnEnum, IntPtr lParam);<br />
<br />
[DllImport("User32.dll")] public static extern int RealGetWindowClass(int hWnd,StringBuilder pszType,uint bufferSize);<br />
[DllImport("User32.dll")] public static extern int SendMessage( int hwnd, int uMsg, int wParam, [MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)] string lParam);<br />
<br />
[DllImport("User32.dll") ] public static extern int FindWindow (string lpClassName,string WindowName);<br />
[DllImport("User32.dll") ] public static extern int FindWindowEx (int hWnd,int hWnd2,string lpsz,string lpsz2);<br />
[DllImport("User32.dll") ] public static extern int SetWindowText(int hWnd,string lpsz);<br />
#endregion<br />
<br />
#region Constants + fields<br />
public static int GW_HWNDNEXT = 2;<br />
public static int GW_CHILD = 5;<br />
public static int GW_OWNER = 4;<br />
public static int GWL_HWNDPARENT = -8;<br />
public static int WM_SETTEXT = 12;<br />
public const int HWND_MESSAGE = -3;<br />
public const int BM_CLICK = 0x00F5;
public const int WM_CHAR = 258;<br />
private string _windowText = "";<br />
#endregion<br />
<br />
#region Callback functions for listing windows<br />
private bool displayAPPLogin(int hWnd, int lParam)<br />
{<br />
StringBuilder windowName = new StringBuilder(255);<br />
StringBuilder className = new StringBuilder(255);<br />
<br />
GetWindowText(hWnd, windowName, 255);<br />
RealGetWindowClass(hWnd,className,255);<br />
if ( windowName.ToString().ToLower().IndexOf("<Name of Login Window>") != -1 )<br />
{<br />
data = hWnd;<br />
}<br />
<br />
return true;<br />
}<br />
<br />
#endregion<br />
<br />
#region Sendmessage clicks<br />
public void PerformAPPLogin()<br />
{<br />
int hWndAPPLogin;<br />
<br />
hWndAPPLogin = (int) data;<br />
<br />
if ( hWndAPPLogin != 0 )<br />
{<br />
int hWndAPPLoginUserName;<br />
int hWndAPPLoginPassWord;<br />
int hWndAPPLoginOKButton;<br />
<br />
hWndAPPLoginUserName = FindWindowEx(hWndAPPLogin,0,"Edit",null);
SendMessage(hWndAPPLoginUserName,WM_SETTEXT,0,"<UserName>");
hWndAPPLoginPassWord = FindWindowEx(hWndAPPLogin,hWndAPPLoginUserName,"Edit",null);
SendMessage(hWndAPPLoginPassWord,WM_SETTEXT,0,"<Password>");
hWndAPPLoginOKButton = FindWindowEx(hWndAPPLogin,0,"Button", null);
SendMessage(hWndAPPLoginOKButton,BM_CLICK,0,null);
}<br />
}<br />
<br />
#endregion<br />
<br />
#region Get APP Login Window<br />
private void getAPPLogin()<br />
{<br />
bool APPRunning = false;<br />
<br />
Process[] processes = Process.GetProcesses();<br />
for (int i=0;i <= processes.Length -1;i++)<br />
{<br />
if (processes[i].ProcessName.ToLower().IndexOf("<Name of Process>") != -1)<br />
{<br />
APPRunning = true;<br />
}<br />
}<br />
<br />
if ( APPRunning )<br />
{<br />
<br />
EnumWindowsCallback EnumWCB = new EnumWindowsCallback(displaySAPLogin);<br />
EnumWindows(EnumWCB ,0);<br />
<br />
}<br />
}<br />
<br />
#endregion<br />
<br />
}<br />
}<br />
I reject your reality and substitute my own!
- Adam Savage, Mythbuster
- George W Bush
life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
|
|
|
|
|
Hi to all.
My name is Bruno and I am an Italian programmer.
I've a problem.
I need to write a program that make a map for apply texture on a various images that contains object (ex. Sofa', chairs, dressed, ...) to change his color/textures.
I've founded software. Look at this:
http://www.nedgraphics-porini.com/Default.aspx?SiteID=7&PageID=166
I've marked 3 extremely hard phases.
1: create a map for curves and angles:
- Algorithm to draw a 3d curve with GDI (2D)
- Algorithm to transform create curve
- Save the curve for future visualization
2: Map texture to curve (texture mapping)
3: Overlay original image with textured map
For the third phase I've supposed to use the base pixel brightness and draw the texture pixel with the same brightness.
The result is ok but work fine just with flat colors because if I use a texture this is so flat.
Therefore I need texture mapping.
Have you a line guide for me?
I've considered using Ray Casting technique or quite DirectX/OpenGL
Tanks for your time.
Bruno
Sorry for terrible English
|
|
|
|
|
|
I need control (.net or ActiveX) to draw 3d graphs in my application... What can you suggest?
|
|
|
|
|
hi all,
i'm trying converting numbers to alpha. for example if i write 30 it'll give me "thirty" or 31 - "thirtyone"... how can i do that?? thanx...
|
|
|
|
|
Wow, that would not be too hard but would require more time to explain than I think most of us would be willing to put in, but if it's okay, let me get you started and I think you can figure the rest out on your own.
seperate your problem into periods. A period is the three number grouping deliniating hundreds, thousands, millions .... ie 42,233,123 so this should convert to the string "fouty two million, two hundred thirty three thousand, one hundred twenty three" right?
so now you have three strings : "42" , "233", "123"
now take each of those strings and make a post-period-word for them to tack on later, so you'd have: "Million", "Thousand" Dont worry about the last string, that one will just be worded on its own.
now convert the number in each of the strings and convert them into words. You can figure this out on your own and its not too hard but think carefully about it, there are some special cases here!
This is kind of a recursive algorithm but there are a few special cases you'll need to code for like
not wording the last group. For instance you would not want to save "One Hundred Twenty Three Hundred".
Have fun.
|
|
|
|
|
|
can any one giude me how to convert ...below vb.net code to C#......
Dim oDoc As Word.Document
Dim oBuiltInProps As Object
Dim oCustomProps As Object
Dim oProp As Object
Dim strValue As String
'Get the Custom Document Properties collection.
oCustomProps = oDoc.CustomDocumentProperties
'Add a property named Status Report
'and give it a value of 4th Qtr.
oCustomProps.Add("DOCID", False, _
Office.MsoDocProperties.msoPropertyTypeString, "123216")
major problem is with oDoc.Custo mDocumentProperties which returns object...how t o do the same thing in C# where oCustomProps.add is not coming?
urgent plz help me out?
|
|
|
|
|
The problem is in declaring oCustomProps as Object. You need this to be of the correct type (DocumentProperties?) so that the Add method is available. In VB.Net:
Dim oCustomProps As DocumentProperties<br />
oCustomProps = oDoc.CustomDocumentProperties<br />
oCustomProps.Add(.....
in C#:
DocumentProperties oCustomProps;<br />
oCustomProps = oDoc.CustomDocumentProperties;<br />
oCustomProps.Add(.....
Hope that helps
Jon
|
|
|
|
|
hai..
i have i tried this but it says it cannot convert object to microsoft.ofice.core.documentproperties
here is my code
DocumentProperties oCustomProps;
oCustomProps = objWordDoc.CustomDocumentProperties;
oCustomProps = (Microsoft.Office.Core.DocumentProperties) oCustomProps;
oCustomProps.Add("Document ,false,MsoDocProperties.msoPropertyTypeString,"123456",null);
|
|
|
|
|
Try merging the two middle lines together:
DocumentProperties oCustomProps;<br />
oCustomProps = (Microsoft.Office.Core.DocumentProperties) objWordDoc.CustomDocumentProperties;<br />
oCustomProps.Add("Document ,false,MsoDocProperties.msoPropertyTypeString,"123456",null);
|
|
|
|
|
even this code throws an error but it is runtime error...regarding RPC
DocumentProperties oCustomProps;
oCustomProps = (Microsoft.Office.Core.DocumentProperties) objWordDoc.CustomDocumentProperties;
oCustomProps.Add("Document ,false,MsoDocProperties.msoPropertyTypeString,"123456",null);
error
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in OfficeDocument.exe
Additional information: The object invoked has disconnected from its clients.
|
|
|
|
|
Hmm I don't think I can help with that, I haven't used COM interop at all or any of the office programming components. I expect somebody will be along who knows what they're talking about!
Jon
|
|
|
|
|
Hi All,
I have downloaded SAP.Net connector from sap.com and with the help of the code available at http://www.codeproject.com/dotnet/SapDBReader.asp, I am able to connect to SAP R/3 System and fetch the data.
While fetching the data from the table having rows more than 200,000, It is giving the error related to BUFFER.
Can anybody help me out for this problem ?
Regards
Dilip
|
|
|
|
|