|
Hello, Heath!
Thanks in advance!
I want to get TextBoxes to function as for example CheckBoxes : immedeatly apply Text changes to bounded property. Example of that You can see in VS Project Properties dialog : if I change any setting in the Property Grid and then move mouse on to Apply button which is not enabled yet and then press mouse button this ENABLES Apply button but not clicks on it and when You do second press it clicks button. How can I do that? When I clicking on my Apply button which is Disabled currently edited textbox does not loose focus! How can I catch that user is going to stil focus from currently focused control? In VS when I press mouse button first time Apply button is enabled but focus is still in property grid
Thanks
|
|
|
|
|
Again, that's a focus issue. When you attempt to set the focus to a button (even though it doesn't gain focus since it is currently disable) the TextBox looses the focus which commits the text and then the TextChanged event is fired. Again, if you want the Apply button be enabled upon making any change regardless of focus, you need to handle one of a couple different of events (like KeyUp ) or override several methods (like OnKeyUp ) in a derived class.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
anyone know any good tool for reformatting c# code.
and by reformat i mean move all public methods to one place , all public propps to another etc etc.
//Roger
(i saw an addin/macro that did that once but i forgot the name)
|
|
|
|
|
|
Hi Guys,
I was able to create a program which will run 3 process at the same time using threads but the criteria or paramaters that I used is HARDCODED (IP ADDRESS/PORT). Now I need to create the same program using threads but the only difference is that IP/PORT is coming from the table and I need to pass it from the class one at a time.
Please somebody help me I'm not good in CLASS, i'm trap with this thing, this is the only one left....
dabuskol
|
|
|
|
|
Just create a class to from which the thread is started that hold these values like so:
using System;
using System.Threading;
public class MyClass
{
public string s1, s2, s3;
public MyClass(string s1, string s2, string s3)
{
this.s1 = s1;
this.s2 = s2;
this.s3 = s3;
}
public void Start()
{
new Thread(new ThreadStart(StartInternal)).Start();
}
private void StartInternal()
{
}
} This is a VERY basic example, but should hopefully give you one idea.
Another way is to pass arguments to the thread. The Thread class isn't capable, but ThreadPool.QueueUserWorkItem is:
object[] parms = new object[] {"Test", 1, Color.Red};
ThreadPool.QueueUserWorkItem(new WaitCallback(SomeMethod), parms); If you want more ideas, click "Search comments" above because we've discussed this many times in the past. You should also read about Threading[^] in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Guys,
Thank You very much.
my problem right now is that when I run my program it gave this error message:
"THE I/O Operation has been aborted because of either a thread exit or an application request"
Here is the code where the took place.
public void OnDataReceived(IAsyncResult asyn)
{
try
{
CSocketPacket theSockId = (CSocketPacket)asyn.AsyncState ;
//end receive...
int iRx = 0 ;
iRx = theSockId.thisSocket.EndReceive (asyn);
char[] chars = new char[iRx + 1];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
System.String szData = new System.String(chars);
txtDataRx.Text = txtDataRx.Text + szData;
WaitForData();
}
catch (ObjectDisposedException )
{
System.Diagnostics.Debugger.Log(0,"1","\nOnDataReceived: Socket has been closed\n");
}
catch(SocketException se)
{
MessageBox.Show (se.Message );
}
}
I'm connecting to server(s) and then retrieving data and insert in into my SQL database.
/dabuskol
|
|
|
|
|
Is OnDataReceived the callback for when the asynchronous call completes? If not, you're not waiting for the data to be received, unless somehow that's what WaitForData is doing (but since you're not passing the asynchronous data, I don't see how it could).
For more information and lots of examples on asynchronous programming, see Including Asynchronous Calls[^] in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am building an add in for Visual Studio .NET and I want to programmatically access the “Find Symbol” feature as well as the “Go to Reference” and “Go to Definition” features from my code. Does anyone know how to call those functions from code?
Thanks.
|
|
|
|
|
Does C# have a propertybag object? I guess, better yet would be a question for the most efficient means to store settings at design time for usercontrols? Any and all suggestions are welcome.
Thanks,
Dave
|
|
|
|
|
They're called properties. Any properties on your control are serialized to the code file. Your designer for the control (if you provide one) can also create PropertyDescriptor s that hold the value of design-time variables or expose other aspects of the code (such as the access modifier or localization settings) as properties.
For more information, see Enhancing Design-time Support[^] in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
In my app I have a custom button class that contains an Icon field.
I choose an icon for the button, save this icon in the buttons icon field and set the icon to be displayed on the button. So far everything works great and the icon on the button looks fine.
Now, I want to save the button's icon (along with other info Im using), so I serialize it.
However, when I deserialize the info and create a new button using the deserialized icon, the icons image quality is poor. It looks like its using less colors or something. The same thing happened when I used bitmaps intstead of icons.
I dont have much experience with image manipulation so if anyone knows what could be causing the drop in quality please let me know.
(Is there a way to set the image quality of the deserialized icon to that of windows)?
Thanx
-Flack
|
|
|
|
|
Button button1=new Button();
button1.Parent=this;
button1.Bounds=new Rectangle(20,20,256,256);
button1.Image=new Bitmap(@"C:\Windows\soap bubbles.bmp");
FileStream fs=new FileStream("iconser.bin",FileMode.OpenOrCreate,FileAccess.Write,FileShare.None);
BinaryFormatter bf=new BinaryFormatter();
bf.Serialize(fs,button1.Image);
fs.Flush();
fs.Close();
FileStream fsOut=new FileStream("iconser.bin",FileMode.Open,FileAccess.Read,FileShare.None);
Image img=(Image)bf.Deserialize(fsOut);
Button btn=new Button();
btn.Bounds=new Rectangle(300,20,256,256);
btn.Parent=this;
btn.Image=img;
|
|
|
|
|
I meant, in this example no image quality loss can be observed.
|
|
|
|
|
I have an outlook bar with a bunch of buttons. When you click one of the buttons, it will open a certain program. The only problem that I have is that it opens the program about 20 times. Any ideas?
Here is the code for opening the program:
<br />
private void clickAction(object sender, System.EventArgs e)<br />
{<br />
Process.Start(@"....");<br />
}<br />
Thanks.
By BigBlob202
Dinco Inc.
|
|
|
|
|
Yeah, don't click it after a second time. If you need only one instance of these programs, then write them accordingly. There are several articles here on CodeProject on how to write single instance applications. You could easily adapt this to make your application stick with a single application instance if the application is beyond your control. Mutexes make this easy.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
how to get Serial Number of a flash memory pluged into the USB port?
or any information about the pluged device into the USB port?
|
|
|
|
|
|
I have a brokerage account that provides streaming real-time stock quotes via an internet applet and I'd like to import the data into a C# application for further manipulation. Two ideas that occurred to me are
1)Screen scraping the data from the applet window on my desktop, and
2)Intercepting the TCP data stream as it comes across port 80.
Unfortunately, I haven't done much work with Windows API and can't figure out how to implement either one. Any thoughts or suggestions?
|
|
|
|
|
|
hi im wondering how do i take a selection from a list and store it in a database...do i have to
1. make the selection
2. take the selection and store it into a string
3. store the string into the database
or
1. make the selection
2. store it into the database by doing this
"INSERT INTO Pharmacy ListboxColumn Values '"+listbox.selecteditem+"'";
also how do i take multiple selection and store it in a string?
txh in advance
|
|
|
|
|
ASGill wrote:
store the string into the database
Look and search for SqlCommand ,SqlDataAdapter in MSDN and this site for sample.
ASGill wrote:
. take the selection and store it into a string
Look for ListBox.SelectedValue in MSDN
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
got it working mazdak!....thx alot for ur directions..
anyways, im kinda curious here.... when i've completed my app and i'd have to present it in a networked environment..what do i need for my app to run on a completely different machine...like Java's got their Virtual Machine (JVM) and such..also pls tell me the list of OS's thats compatible with a .Net app. i know i can get all this info from the internet...i just wanna doubl confirm..so that im not doin anything wrong..
also...im trying to implement a splash screen, how do i start my app with splash screen first...
i tried
[STAThread]
{
Application.Run(new frmSplash);
}
but then the splash screen does not wanna close at all...how do i go about this.
oh yeah and another thing...can i have your name...i'd like to add it in my acknowledgement and also referrence.
thx in advance
Arvinder Gill
|
|
|
|
|
For your first question you need to install .NET framework on each machine you want to run your application. Also if you use ADO.NET (which you used) you need to install latest version of MDAC on that machine, specially if that OS is not WinXP.
About spalsh screen, I haven't done it myself in C# but if you want to put it before Application.Run() you have to close before it too cause that line actualy doesn't finish until you close your application. You can first show splash, then use sleep function for wait some seconds,then close it. Same thing can be done in Load event too, but I don't know best solution until I test it myself.
ASGill wrote:
can i have your name...
Well, you already know it. My name is Mazdak.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
hi mazdak
sorry maz...im a lil bit blur here right now...what's MDAC??...
CODER
|
|
|
|