|
Just build a custom user control.
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
Click here to view my blog
|
|
|
|
|
Look at the example here [^]at MSDN.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I want to develop an application in C# to access a remote desktop and show it to another computer. Like I'm the server and there's two clients, one whose desktop i'm getting, and the other client will see it. I would like to know how to start to develop such an application. Please give me some useful links or documents or anything for initial starting.
|
|
|
|
|
I might have asked this before, but I never got any good answer.
How do I implement an excel like selection?
I have a collection of many controls arranged in lines and rows, much like excel cells.
The user i supposed to select them like cells in Excel, but it just won't work.
The controls' MouseDown and MouseEnter event apparently cause the control to own the mouse and make it impossible to fire events on any other control as long as the mouse button is held down.
I also got this code on msdn, but it's utter rubbish. It will cause a single control to flicker between selected and unselected madly, it's not possible to select multiple controls and the control isn't drawn while you hold the mouse over it.
Point start;
private void pictureBox_MouseDown(object sender, MouseEventArgs e)
{
start = e.Location;
}
private void pictureBox_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Size selSize=new Size(e.X - start.X, e.Y - start.Y);
Rectangle selRect = new Rectangle(start, selSize);
selRect.Offset(((Control)sender).Location);
foreach (Control ctl in this.flowLayoutPanel1.Controls)
{
if (ctl.Bounds.IntersectsWith(selRect))
{
ctl.BackColor = Color.Yellow;
}
else
{
ctl.BackColor = Color.Gray;
}
}
}
} So, does anyone have a solution or at least a hint?
Tanks a lot!
|
|
|
|
|
Why is your mouse move firing for movement only in a picture box ? This code looks pretty logical to me.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
for first time i want to distribute a software with database in c#
in my software i have a datagridview that linked to a database and saved the changes
if i want create a setup project for distribution this software whether this database
with all of it's data copied to my project or not ?
|
|
|
|
|
Well, the real question is, what database do you use ? An Access DB can possibly be just distributed, but a SQL Server DB needs SQL Server to be installed, a connection string configured, etc.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Dear christian
Thanks for your answer
Now i have a sql DB that connected to my C# program and have app.config file for DB connection
Whether if i create a setup project from my software and install it on another computer
my DB copy to new computer or not ?
|
|
|
|
|
I want to make a game draw its Board so I have been trying to pass the graphics object. I get an error saying that the
NullReferenceException
"Object reference not set to an instance of an object."
I use
In the form's Paint function
Graphics g = this.CreateGraphics();
game.DrawBoard(g);
game is a variable in the form and DrawBoard is a function of that class
public void DrawBoard(Graphics g)
{
....
}
I have also tried passing the PaintEventArgs e with the same result
It works if I make the function belong to the form but that is not what I want to do
I vaguely remember from C++ that I might need to use handles but I have not been able to find a solution.
Can anybody help?
Alan
|
|
|
|
|
Chances are your game variable isn't instantiated
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Thanks everybody.
I had instantiated game in the Form load function but that must have ben too late.
I understood the debugger to be telling me that the Graphics object was Null. I never thought of the game object being Null
Finally, Why is CreateGraphics() wrong? It's use is in all the "how to do it pages on Google" I only vaguely knew about the possibility of using e.Graphics from using C++
Alan
|
|
|
|
|
Hi,
Member 950420 wrote: I understood the debugger to be telling me that the Graphics object was Null
The exception provides line information when available (normally so while debugging); and of course you have set your Visual Studio editor to always show line numbers (menu Tools/Options/TextEditor/AllLanguages:display line numbers), so you immediately can tell which line went wrong.
Member 950420 wrote: Why is CreateGraphics() wrong?
CreateGraphics() creates a new, large, complex object, whereas the one in PaintEventArgs is already there. And the one you got from CreateGraphics() needs to be Dispose()d of, otherwise you will run into delayed memory collection situations; anyhow it will slow down your app in case you have frequent repaints (e.g. when animating something).
Member 950420 wrote: how to do it pages on Google
Whatever you find on the Internet may or may not be correct; lots of examples are incorrect, i.e. they seem to function but contain fundamental flaws that will show under some circumstances. Read a serious book on the topic of interest, read some top-notch articles, and read the documentation, then judge everything you encounter for yourself.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Member 950420 wrote: Graphics g = this.CreateGraphics();
This is wrong. Never do it. Instead, handle the paint event, and use the graphics object passed in to that. Otherwise, if your form is obscured and then shown again, it will not redraw itself.
Member 950420 wrote: I have also tried passing the PaintEventArgs e with the same result
Yes, that is the ONLY way to do it, unless you're drawing rubber bands or other things you want to lose easily by calling Invalidate().
Member 950420 wrote: NullReferenceException
"Object reference not set to an instance of an object."
and, as someone already said, this ALWAYS means an object is null. You should learn to use the debugger, then you'd be able to work out which objects are not initiated, by stepping through the code.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
don't use CreateGraphics except for very special circumstances; use the Graphics that is inside PaintEventArgs instead.
chances are the Paint event fires before your game has been fully initialized, so add a null test on game inside the Paint handler.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi
i'm looking for a container control like visual studio toolbox, which on mouse over, it display content controls and on mouse leave, it hide it's content.
can anybody help me ?
Note : i want to add some controls like textBox,comboBox, ... to it, not toolStrip or toolBar controls.
thanks
|
|
|
|
|
Nothing exists, unless it's in a CP article or third party library. Search CP, and then consider if you need to write it yourself.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi Christian
i don't know what's the name of this control to search it.
can u help me ?
|
|
|
|
|
I have no idea either, except that you'd probably search based on behaviour 'Visual Studio toolbox control', for example.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
I hope some one out there can help me! I have been goggling my brains out all day tiring to find the answer for this question I have:
I'm using visual studio 2008 and I am pretty much a noob to c#. So go easy on me.
Trying to write a console app that checks the status of a windows service and if it is up stops it and if it's down brings it up! But the problem is that the book I am using to teach myself c# in vs 2008 does not describe this. And also to code that I do find on the web is for 2005 and doesn't work in 2008! I might look a bit liker this:
public static void StartService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch
{
// ...
}
}
But as I stated earlier the ServiceController class doesn't seem to work in 2008, or I could just be a dim whit...
So any idea you might have as of how I might do this would make my day!
Thanks in advice,
Mike
|
|
|
|
|
If you are not getting an exception how do you know the service has not started?
Depending on what OS you are on, the OS properties are reported diffrently.
Take a look at the win32 to .NET API cross refrence.
Microsoft Win32 to Microsoft .NET Framework API Map[^]
|
|
|
|
|
I could be way off here but if you're using Vista (or possibly Weven), IIRC you can only stop and start services if you add a manifest file and elevate to administrator (yeah - that brings in the UAC prompt for your app).
It's a long time since I've tried this so I may be wrong, but I think that this is the case, and also if my memory serves correctly, you don't get any exception - it just doesn't work.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Mike,
It did work for me on VS 2008. Here is my program -
using System;
using System.ServiceProcess;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
ServiceController service = new ServiceController("<<Your Service Name>>");
service.Stop();
TimeSpan timeout = TimeSpan.FromMilliseconds(10000);
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
if (service.Status == ServiceControllerStatus.Stopped)
{
service.Start();
}
}
catch
{
// ...
}
}
}
}
Are you getting any specific error ?
|
|
|
|
|
First of all I would like to thank every one who has tried to help me thus far, it great! As I said im a noob at c# getting this type of help will bring me to the next level (even if its a still a low one )
I'm am using vista....
when using Shukla's great piece of code I get this:
The problem might be missing a reference?
Error 1 The type or namespace name 'ServiceProcess' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Users\mike\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs 2 14 ConsoleApplication1
The problem might be missing a reference?
Also the ebook (Microsoft.Press.Microsoft.Visual.C.Sharp.2008.Step.by.Step)I use to teach myself is not telling me how to link in a external .dll so if you have any good references on this subject I would love to know!
Anyway thank you for you time!
|
|
|
|
|
Hey,
I am programing a program that uses a Web Service to connect between the Server and WinAPP forms.
I made the web service and active my IIS 7 (Using vista ultimate), then i enterd into my localost(using IP) and all go ok (check my defined methods and they returned void XML data)
But when i combine that web service to WinAPP and them bind data to datagrid i got error:
System.Net.WebException: הבקשה נכשלה עם הודעת השגיאה:
--
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="%2fUniversityWebServices%2fService.asmx%3fAspxAutoDetectCookieSupport%3d1">here</a>.</h2>
</body></html>
--.
ב- System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
ב- System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
ב- WindowsUniversityClient.UniversityWebReference.Service.GetGradesByStudentId(Int32 id) ב- C:\Users\יהב\Desktop\UniversityTestOrgnizer\UniversityTestOrgnizer\WindowsUniversityClient\Web References\UniversityWebReference\Reference.cs:שורה 83
ב- WindowsUniversityClient.Form1.searchgrades_btn_Click(Object sender, EventArgs e) ב- C:\Users\יהב\Desktop\UniversityTestOrgnizer\UniversityTestOrgnizer\WindowsUniversityClient\Form1.cs:שורה 24 the code i userd
UniversityWebReference.Service service = new WindowsUniversityClient.UniversityWebReference.Service();
try
{
this.grades_dataview.DataSource = service.GetGradesByStudentId(int.Parse(this.studentid_txtbox.Text));
}
catch (FormatException format_e)
{
MessageBox.Show(format_e.Message, "נוצרה שגיאה במהלך הצגת הנתונים", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch(Exception ee)
{
MessageBox.Show(ee.Message, "נוצרה שגיאה במהלך הצגת הנתונים", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Gindi Bar Yahav - Web & Software defeloper.
modified on Saturday, June 20, 2009 10:43 AM
|
|
|
|
|
Hmm, my Hebrew is no so good, but you might try using: int.TryParse() instead of int.Parse(). Also, it is good to use some debug methods for inspecting the SOAP message before and after it is processed. You can do this in debug mode in Visual Studio. Make sure your IO is working correctly. This is the half split, method for finding bugs in SOAP based web services. Then depending on where the problem is manifesting you will know what end point is responsible for the problem.
|
|
|
|