|
Thanks, Luc! I'll check those suggestions after work tonight. By the way, the textbox names are correct, and meant to help me keep them straight, as they are the names of the variables in the equation that are to be entered in each (D= diameter, d = depth, W1 = width1, W2 = width2). The Sender/sender thing is just my fat fingers habitually hitting the caps key; I changed them just now with no effect.
I'll try the rest later.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Roger Wright wrote: The Sender/sender thing is just my fat fingers habitually hitting the caps key
No problem, except you never should feel a need to type those lines at all; either you wire the event trough the properties of the Control (the lightning tab lists the events), or you type myControl.someEvent+= and Intellisense takes over; hitting TAB twice generates the outline of the event handler for you. Doing neither of those increases the possibility something wasn't done right.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hmmm. You lost me there. What's a 'lightning tab'? Since there's no such thing as a manual anymore, I have only a vague idea of what the IDE will do.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
inside Visual Studio, open up visual designer for the form/user control you're interested in.
select the entire form/UC or one of its Controls.
right-click it for properties (or use some menu or toolbar item); this opens the property pane.
in the property pane, you get to see 5 buttons (Categorized, Alphabetical, Properties, Events, Property Pages); they all have icons, the "Events" icon is a yellow lightning strike. That is the magical one. Click it!
Now in the list, search the event you want, and click the right cell to choose amongst the existing handlers, or double-click to create a new one.
works on all versions I can remember.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
I checked it out, and it's still there; a pity I never found it before.
Our friend dybs had the right answer, though. The Designer didn't contain a link to the handler, and a quick edit fixed that. All of the above is now working perfectly, except for the annoying "bonk" sound when I press Enter instead of Tab to move to the next field. Perhaps that's a quirk of the Debug mode and won't show up in the release version.
Now there's a new glitch, so I'll post a fresh question. Thanks for your help!
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
your "bonk" is probably an auditive signal emitted by some component you added in order to check validity and report any problems. One example would be a MaskedTextBox (you only mentioned TextBox) with its property BeepOnError set true.
If so, it will act the same in debug/release and inside/outside Visual.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Nope - I'm not yet smart enough for that. I didn't know that such a thing exists. Nothing here but labels and textboxes, all unmasked. Maybe it's hamsters farting and laughing at my terrible code?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
So I investigated your "bonk". Seems like all TextBoxes will do that by default, when present on some forms, probably all modeless forms, such as your main form.
What you are hearing most likely is a "beep" (at a high volume level). It is one of the Windows signals (a virtual sound), which by default probably causes "Ding.wav" to be played.
You could tell your PC to never do that (through the "Sound" control panel); a bad idea.
You could modify your app and have the TextBoxes swallow the unwanted characters (there probably are a lot of them, try ESC!)
The remedy is to add a KeyDown handler (and wire it up to the textbox) that decides which characters to process or not to process, something like:
private void aTextBox_KeyDown(object sender, KeyEventArgs e) {
Keys k=e.KeyCode;
if (k==Keys.Enter) {
e.Handled=true;
e.SuppressKeyPress=true;
}
}
Of course you noticed that this little filter did not refer a specific TextBox, so it could be wired up to a lot of TextBoxes.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Roger Wright wrote: dybs had the right answer
You may want and read my very first hint again, here[^].
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
I was still working on my reply by the time yours was posted.
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
Have you double-checked the values for txtDh, txtdW1 and txtW2 in InitializeComponent, just to make sure VS didn't do something wiered like remove/forget to add your event handlers? I've had strange things happen before where in the designer, a property shows me a certain value, but the Designer.cs file shows me something completely different (neither values being the default for the property).
Roger Wright wrote: when trying to step through the program, each key click advances correctly through the Program.cs file, then it shifts to the Designer file to initialize the Form object. When that's done, my form is displayed, then it moves the cursor back to the Program.cs file
I think this is actually normal behavior because after the form's constructor finishes, it's just the message loop running to process events. Nothing else should be happening in your form.cs file until you click one of you buttons or enter some text (at least given what you've described here). I could be wrong on the message loop thing, but this at least fits with my experience.
Dybs
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
I'll check that later tonight.
I think you're right about the behavior, but when I enter text I expect the cursor to shift back to my main Form file, and step through the lines of the code being executed. It's not doing that. Weird...
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
You nailed it - the Designer page didn't have any handlers assigned to the text boxes. A quick edit fixed that. That's my own fault. I didn't know about the Events tab in the Properties window and just typed in a handler, assuming that Visual Studio would figure it out. It didn't, and I can't blame the product for that (though the lack of a proper manual is largely to blame).
Thanks for your help, and keep an eye on this space. I'm about to post another question, hopefully the last, as I'm now at the finish line for my calculator and the last calculation is screwing me up badly with unexpected behavior.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
HI...
I managed searching in google to make a call to a server which returns me data from different GPS devices so I can save to a database. The problem is that I need to do the same but in two different server at the same time, ie, I need to get data from two different URL and save them in my database.
This is what I achieved.
try
{
byte[] buf = new byte[8192];
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://xxx.xxx.xxx.xxx:7778/online?user=xx&pass=xxx");
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
Stream resStream = response.GetResponseStream();
//int count = 0;
//string tempString = "";
Thread t = new Thread(delegate() { Go(buf, resStream, listaRelojes); }); // No need to explicitly use ThreadStart
t.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
public void Go(byte[] buf, Stream resStream, LinkedList<reloj> listaRelojes)
{
int count = 0;
string tempString = "";
tempString = Encoding.ASCII.GetString(buf, 0, count);
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
Parse(tempString, listaRelojes);
System.Console.Out.WriteLine("my System: " + tempString);
}
} while (count > 0);
}
I need something like this I think :
WebRequest.Create("http://xxx.xxx.xxx.xxx:7778/online?user=xx&pass=xxx"); and
WebRequest.Create("http://yyy.yyy.yyy.yyy:7779/online?user=yy&pass=yyy");
at the same time.
Is this posible???
Thank´s in advance.
Christian...
|
|
|
|
|
If you can open up two different browser instances, and successfully issue those URL requests in each of them simultaneously, I see no reason why two WebRequests wouldn't work equally well. However, I never did anything of that kind.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Try threading with BackgroundWorker, Threads or CCR. I have done it myself on a recent project using CCR. But at first instance i suggest you give the BackgroundWorkers a shot.
Regards
Jens
When in trouble,
when in doubt,
run in circles,
scream and shout
|
|
|
|
|
You can create the two requests as you like and then call BeginGetResponse() on each of them (MSDN Reference[^]).
This will probably be the easiest way to get what you want without getting entangled with thread pools (and possible starvation).
|
|
|
|
|
Hello,
I need to determin the COM component(unmanaged code) type and invoke the exposed interface's methods using reflection in C#.NET at runtime.
1 -- First What member of "Type" tells that type is COM component and we can take CLSID at runtime? Is Type.COMObject?
2 -- I need to call methods of exposed interfaces as they called in unmanaged code using CoCreateInstance by passing CLSID and REFID ... I am using InvokeMember but it returns null or 0 as out parameter.
How to pass out parameter in this case.? Is there any need to pass out parameter? As all my COM unamanged code suppose to take las parameter as an OUT parameter and after executing it puts the result into that out param. But I've converted all my unmanged COM code to .NET managed assemblies using tlbimp.exe.
Regards
Usman
|
|
|
|
|
1.You could use Type.IsCOMObject to determinate if this is an instance of COM object.
2.You could get Syste.Type instance by using Type.GetTypeFromCLSID or Type.GetTypeFromProgID .
You really needn't to call CoCreateInstance you could just use
System.Activator class instead of and Marshal.FinalReleaseComObject to free it.
Life is a stage and we are all actors!
|
|
|
|
|
Hello,
I just completed a C# application (VS 2008) and was attempting to put an icon in the bar when I got an unusual error message. It states that the Icon argument will only accept a picture as an icon, even though the menu is calling for an .ico file. I have tried a few different files just to be sure, but all derive the same message. There is a default icon already loaded and I need to replace it. Although this is just a click and install item, I am baffled (and almost embarrassed) as to why I am getting this message and I am unable to load a file. Please tell me what I have missed....?? Thank you, Pat
|
|
|
|
|
is the .ico file and actual icon (or just a renamed bitmap). It may be worth checking in an icon editor ([^])
|
|
|
|
|
Thank you Martin,
Not sure how that could have happened, but you are exactly correct. Apparently, the file was marked as an Icon but the application did not recognize it as one. I appreciate your help and have marked your answer as the correct solution.
Best regards, Pat
|
|
|
|
|
Thanks to everyone for you help in advance.
I have a Grid that currently has a column that does not fill with data from the db but with an image depending on a condtion met. What is the same method but not a rendering method that draws a graphic but rather fills cell with text.
something like:
if (D.Flags == 1)
{
........?? //Draw Text = "Warning"
}
namespace Freepour.Studio.Controls.Grid
{
public class InventoryWorksheetGridImageColumn : GridImageColumn
{
.....
protected override void DrawCell(Divelements.SandGrid.Rendering.RenderingContext context, GridRow row, object value, Font rowFont, Image image, Rectangle bounds, bool selected, Divelements.SandGrid.Rendering.TextFormattingInformation textFormat, Color foreColor)
{
float x = (2) + bounds.Left;
float y = (1) + bounds.Top;
float width = 16.0F;
float height = 16.0F;
object O = row.DataItem;
DownloadAudit D = O as DownloadAudit;
if (D.Flags == 1)
{
context.Graphics.DrawImage(ExclusionImage, x, y, width, height);
}
|
|
|
|
|
This question applies to VB.net and C# so I posted it here in the hope I will get more answers. However, the code will be presented in VB.net. Feel free to respond in C#
The program bellow trhows an error in the line "mTable2 = mTable.Copy". The error is: "Unable to cast object of type 'System.Data.DataTable' to type 'InherintanceQuestion.InheritedTable". This is because mTables is an instance of the InheritedTable class which inherits a DataTable and mTable is a DataTable. So, is there any way I can create the mTable2 to the mTable.copy to the mTable.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mTable As New DataTable
Dim mTable2 As New InheritedTable
mTable.Columns.Add("Col1", System.Type.GetType("System.String"))
mTable.Columns.Add("Col2", System.Type.GetType("System.String"))
Dim Row As DataRow = mTable.NewRow
Row(0) = "A" : Row(1) = "B" : mTable.Rows.Add(Row)
Row = mTable.NewRow
Row(0) = "C" : Row(1) = "D" : mTable.Rows.Add(Row)
mTable2 = DirectCast(mTable.Clone, InheritedTable).Copy
End Sub
End Class
Public Class InheritedTable
Inherits System.Data.DataTable
Private Sub DoSomething()
'Any code.
End Sub
End Class
|
|
|
|
|
for VB, it would be
mtable2 = mTable as DataTable
(or maybe use CType() )
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|