|
|
But say if I was not using forms and I was supposed to display the line "Button was clicked" at the console. I do not want to use the form class. I am writing a console application and not a windows application. I still want the event to be fired. then what? My code I want to actually do that. Target the display to the Console.
|
|
|
|
|
debashish_shona_99 wrote:
Target the display to the Console.
I not touching this with a 40" pole!
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
debashish_shona_99 wrote:
Target the display to the Console.
I'm not quite sure what you're going for here.
Calling your classes "Form" and "Button" doesn't make a whole lot of sense in a non-GUI app. Not to mention the idea of "clicking" something is a GUI concept.
That said, there's nothing in your Button class that actually fires the event.
You can add a public method, such as PerformClick() that call a protected method, such as OnClick(), which then fires the event.
public void PerformClick(){<br />
this.OnClick();<br />
}<br />
protected void OnClick(){<br />
if(Click != null){ Click(); }<br />
}
Then from the Form class:
button1.PerformClick() will cause the event to be fired.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Sorry Charlie I got disconnected. I wish you Merry Christmas and a Very Happy New Year in advance. But I intend to target the Console. This is a console application and not a windows application. I want to display the line "Button was clicked" on the Console. But I still want to use the event and delegate etc. i.e. My event will get fired when I call it from the Main. i.e. I will create a Form Object from Main to call the form class and I will type Form.Button.click. this is when the event will be fired.
|
|
|
|
|
Does anybody know how can I determine what keys are being pressed within other applications? For example I want to know everything typed in Macromedi Flash environment...
I greatly appreciate your answers
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
How would I go about doing a task such as this?
|
|
|
|
|
|
I can't seem to find what you suggested.
|
|
|
|
|
hi, im new to c sharp. i'd like to know how do i add a form to an existing project. and how do i point to it, thx.
Asg58
|
|
|
|
|
This has been covered many times in the past - including a discussion recently. Please search the C# forum comments for links and information. The is a Search Comments link at the top of the messages view.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I've setup a browser in an application similar to what has been explained in this article, when I browse around to one or two different HTML files and then go to a powerpoint document things work fine. If I check out more than one or two HTML files and then go to a powerpoint document, I'm able to click and advance one slide, but further mouse clicks do nothing, not even right clicking. At this point I'm able to use the mouse wheel or the scrollbar on the browser to advance, then everything works fine again.
I've been searching on msdn for any info on using powerpoint within the browser control but haven't been able to find anything yet.
|
|
|
|
|
My web calendar control is correctly populating each calendar cell with the course and time as programmed. Problem: it's creating twins! Each listing is created twice. Stepping through the code revealed that each calendar day is being rendered twice. What do I need to do to nonduplicated entries?
Code Follows:
protected void C1DayRender(object sender, DayRenderEventArgs e)
{
if(courseTable.Rows.Count>0)
{
CalendarDay d = ((DayRenderEventArgs)e).Day;
TableCell c = ((DayRenderEventArgs)e).Cell;
DateTime tempDate;
foreach(DataRow dr in courseTable.Rows)
{
tempDate = (DateTime)dr["sDate"];
if(tempDate.ToShortDateString() == d.Date.ToShortDateString())
{
string s1 = " " + dr["CourseName"] + " " + tempDate.ToShortTimeString();
c.Controls.Add(new LiteralControl(hypRegister.Text = s1));
}
}
}
}
I'm on a crunch deadline, and I think I am just missing a piece of code here to get this function to move to the next date after grabbing any matches in the container.
Thanks, Sally Lay
Sally Lay
|
|
|
|
|
Solved the problem. This calendar does more than reflect a schedule; it is also a registration tool. Removing the "this.Calendar1 += new Calendar1.DayRender;" line in the generated web designer form code made each day render itself only once. Thanks, Sally
Sally Lay
|
|
|
|
|
I have a function that needs to accept a string and append it to another string. I initially implemented it like this:
private String big = "";
...
private void OnIncoming( String small )
{
big += small;
big += "\r\n";
} However this seems to be extremely inefficient. Receiving about 300K of text (which happens to come from the net) in small amounts takes about 1 minute. However, if I simply comment out the contents of OnIncoming (the two += lines) it takes about 5 seconds. So it appears the string concatenation is causing the problem.
How can I improve this? I need to take a bunch of little strings (one at a time), and concatenate them into a larger string. Any suggestions as to what would be the most efficient way to do this in C#?
Thanks in advance for any suggestions, ideas, or assistance!
|
|
|
|
|
You should use String.Concat for up to 4 string parameters, String.Format if you can format your string, or - which can be used for all - a StringBuilder (which String.Format uses internally).
Also, keep in mind that string are immutable while the StringBuilder is not (meaning it can actually grow). When you concatenate strings, the CLR must get the length of both strings, create a new string of the total length, then copy each character from both strings. You're right - it is very inefficient. The methods and class above will help you (and are nice for formatting and what-not, too).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Everyone, I'm hoping to call an unmanaged C/C++ function within a DLL directly from a C# class without having to bother with a managedC++ class as proxy. However, the DLL function includes the MFC CString in its prototype, so I'm thinking that perhaps I'm going to need to.
[DllImport( @"C:\Program Files\MyCompany\MyDLL.dll", CharSet = CharSet.Ansi)]
public static extern IntPtr MyFunction(CString arg1, CString arg2);
I understand that the InteropServices will likely be involved, and I'm about to do
my homework so see what needs to be done, but if anyone knows the answers, then
feel free to fill me in.
Best,
Jerry
|
|
|
|
|
Correct me if I'm wrong, but aren't CString 's Unicode when UNICODE is defined (for applicable OS's)? If so, you should be using CharSet.Auto .
Also, remember that CStr is a wrapper, where the string is actually stored in m_str (or something like that), so you'd probably have to create a related structure and marshal to that struct. In that case, place the CharSet=CharSet.Auto in the StructLayoutAttribute for the struct.
I wish I could tell you more, but it's been a while since I worked with MFC and, believe it or not, CString doesn't show up in the class list!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is it possible to add a button to Internet Explorer's main toolbar (next to the "History"-button)?
Andreas Philipson
|
|
|
|
|
Not right next to the History button, no, but you can find information about adding buttons after the separator to the right of the History button here: Adding Toolbar Buttons[^].
Also, this isn't really the forum for this question.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is there a way that I can create a copy of a textbox out of a TabPage and insert it into another TabPage. The way I've been trying is to add() the TextBox to the second TabPage but this removes it from the first.
I would really like for it to call the same TextChanged() function.
Any suggestions?
Thanks,
Matt
|
|
|
|
|
Point both textboxes at the same TextChanged handler
|
|
|
|
|
Mark's idea is a good one. I just wanted to add that a control can only have one parent. This is pretty much universal and goes down to the Windows Common Controls that pretty much each control in System.Windows.Forms wraps.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have a datagrid and I want the data displayed and allow the user to select a record. But I don't want the blank last row displayed. I don't want them to be able to enter new data in this datagrid. This one is for selecting a record only.
Thanks for any help
|
|
|
|
|
append in your init :
MyDataGrid.ReadOnly = true;
|
|
|
|