|
|
Hello,
If I want to move an object in a panel than I have a lot of strange effects. I use a panel and an button (inside the panel on a form. If I move the button outside of the panel the behaviour of the panel is correct. But if I scroll first outside to the object and the I move the object to the left side. Than the Scollbar isn't anymore there. I have tested already a lot of things but allways I have a strange behaviour.
Has onyone an idea?
I use the following code:
<br />
public partial class Form1 : Form<br />
{<br />
private Point startLoc = new Point(0, 0);<br />
private Point actLoc;<br />
private Point posScreen;<br />
private bool dragging = false;<br />
private Button draggedObject;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
panel1.AutoScroll = true;<br />
panel1.HorizontalScroll.Enabled = true;<br />
panel1.VerticalScroll.Enabled = true;<br />
<br />
button1.MouseMove += new MouseEventHandler(Object_MouseMove);<br />
button1.MouseDown += new MouseEventHandler(Object_MouseDown);<br />
button1.MouseUp += new MouseEventHandler(Object_MouseUp);<br />
}<br />
<br />
private void Object_MouseDown(Object sender, MouseEventArgs e)<br />
{<br />
if (e.Button == MouseButtons.Left &&<br />
sender.GetType() == typeof(Button))<br />
{<br />
Button visObj = (Button)sender;<br />
<br />
posScreen = visObj.PointToScreen(e.Location);<br />
startLoc = visObj.Location;<br />
draggedObject = visObj;<br />
dragging = true;<br />
}<br />
}<br />
<br />
<br />
private void Object_MouseMove(Object sender, MouseEventArgs e)<br />
{<br />
if (dragging == true)<br />
{<br />
Button visObj = (Button)sender;<br />
<br />
int deltaX = MousePosition.X - posScreen.X;<br />
int deltaY = MousePosition.Y - posScreen.Y;<br />
<br />
actLoc.X = startLoc.X + deltaX;<br />
actLoc.Y = startLoc.Y + deltaY;<br />
if (actLoc.X >= 0)<br />
{<br />
int horVal = this.HorizontalScroll.Value;<br />
int left;<br />
int rightObj = actLoc.X + visObj.Width;<br />
if (rightObj >= this.Width)<br />
{<br />
left = actLoc.X;
}<br />
else<br />
{<br />
left = actLoc.X - this.AutoScrollPosition.X;<br />
}<br />
<br />
visObj.Left = left;<br />
}<br />
else<br />
{<br />
visObj.Left = 0;<br />
}<br />
<br />
if (actLoc.Y >= 0)<br />
{<br />
int top = actLoc.Y;
visObj.Top = top;<br />
<br />
}<br />
else<br />
{<br />
visObj.Top = 0;<br />
}<br />
<br />
}<br />
}<br />
<br />
private void Object_MouseUp(Object sender, MouseEventArgs e)<br />
{<br />
dragging = false;<br />
}<br />
}<br />
Regards and thanks for any hint!!!!!
Hansjörg
|
|
|
|
|
I try to set up my installation file, what I need to do is to get values at installation from user, then take those values and write it to my configuration file.
I have tried to add a custom action to my installer but that doesn't work.
when I build the app in debug and the installation files in debug, when I run the installaion it gives me a reference object not set to an instance of an object error.
If I build the app and the installer in release mode, and then run the installer, it completes the installation but makes no changes to the configuration file.
I also created the overloaded installer class where I'm supposed to get the values to write to the configuration file. But don't know if it works or not. Is there any way that you can step through your installation process as you would do with your normal coding?
What exactly is the difference between debug and release.
Anyone who can help or maybe point me into some direction because I have no idea what I am supposed to do or how the installer actualy work.
|
|
|
|
|
Hi!
If you have a custom action in your installer package, you can simply add a call to MessageBox.Show("Attach debugger now"); to the beginning of your custom action's Installer.Install() method.
When you build and run the installation, the message box should pop up and wait for you to click OK.
Then you can attach your VS debugger to the running process and step through your custom action.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Thanx, helped alot.
Now I have another question, with that custom action, how do i select multple values.
ie. on customDataAction /ServerName=[EDITA1];/DBName=[EDITA2]
where
Arguments EDITA1;EDITA2
how do i add multiple arguments, or do i need to add a new custom action for every argument.
|
|
|
|
|
Just replace the ';' with a blank.
You'll get each argument separately, i.e. 2 arguments: "/ServerName=..." and "/DBName=..."
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Thanx a million.
I've been struggling with this installer for the last week.
|
|
|
|
|
I'm having problems with the following code snippet. It executes the first Messagebox within the foreach, but then fails at the if just beneath that.
Can anyone help please.
foreach(XmlNode node in settingNode.ChildNodes)
{
System.Windows.Forms.MessageBox.Show("Inside foreach","Entered");
if(node.Attributes["key"].Value != null)
{
System.Windows.Forms.MessageBox.Show(node.Attributes["key"].Value,"Value");
if(node.Attributes["key"].Value == "ServerName")
{
System.Windows.Forms.MessageBox.Show("Saving Servername","Servername");
NumNode = node;
XmlAttribute att = NumNode.Attributes["value"];
att.Value = ServerName;
doc.Save(appConfigPath);
System.Windows.Forms.MessageBox.Show("Finished ServerName","Servername");
}
if(node.Attributes["key"].Value == "DBName")
{
System.Windows.Forms.MessageBox.Show("Saving dbName","dbname");
NumNode = node;
XmlAttribute att = NumNode.Attributes["value"];
att.Value = DBName;
doc.Save(appConfigPath);
System.Windows.Forms.MessageBox.Show("Finished dbname","dbname");
}
if(node.Attributes["key"].Value == "UserID")
{
System.Windows.Forms.MessageBox.Show("Saving UserId","UserId");
NumNode = node;
XmlAttribute att = NumNode.Attributes["value"];
att.Value = UserID;
doc.Save(appConfigPath);
System.Windows.Forms.MessageBox.Show("Finished UserId","UserId");
}
if(node.Attributes["key"].Value == "Password")
{
System.Windows.Forms.MessageBox.Show("Saving password","password");
NumNode = node;
XmlAttribute att = NumNode.Attributes["value"];
att.Value = Password;
doc.Save(appConfigPath);
System.Windows.Forms.MessageBox.Show("Finished password","password");
}
}
}
|
|
|
|
|
Howdy folks,
I want to learn about developing and using COM+ objects within the .NET world. Can anyone point me in the right direction? Online tutorials or articles? Good books?
thanks,
paully
|
|
|
|
|
|
Hello all!
I am using a C# program and would like to generate the C# application (window application), after compile an exe file from the source code. Can anyone provide some help. I look for msdn but not found.
Thanks All,
Tran Dung
|
|
|
|
|
You can try using System.CodeDom. It allows you to build dynamic assemblies. But its bit complex.
Best Regards
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
hi... i have a problem regarding my transaction number... i make it a randomized one, but what i really want is to make it a...
example: my transaction number now is 000121 then after that transaction it will automatically turn into 000122... is that posible. could you teach me how... THANKS
Chill out!!!
|
|
|
|
|
What kind of transaction are you talking about? SQL transactions? System.Transactions? Client/server transactions?
|
|
|
|
|
So what you want to do is to auto increment the transactions number, with the transaction number being a variable within your code.
If I understand correctly.
Do you only use the app or do you use sql with your app?
I would say that if its just within your app the best would be
int trans = 0;
Number++;
or if you use sql you can set that each new entry must be unique and auto increment where you can specify the starting point and the amount with wich to increment.
|
|
|
|
|
Hi, I'm a newbie at C#, I was wondering if there was a code for knowing the location of the current open C# document. Let's say I want to know the location(In string form) of Form1.cs, is there any code to represent this?
Thank you very much
|
|
|
|
|
Can you be more specific? The opened C# file...are you trying to find out the file path of a C# file Visual Studio has opened?
|
|
|
|
|
Yes. Because I want to access a folder that is located in the same folder as the file but I can't seem to access it.
it looks like this:
Folder1 contains
-Form1.cs
-FolderIwantToAccess contains pic.bmp
I want to access pic.bmp from Form1.cs
Thanks a lot!
-- modified at 22:35 Monday 6th February, 2006
|
|
|
|
|
Your .cs file doesn't execute directly. It gets compiled into your .exe file located in your \bin\debug\ directory. So your C# code will want to locate the bitmap relative to that directory.
If your directory structure is
MyProject
-FolderIWantToAccess
-bin
-Debug
Then you can access the image from your app using "..\\..\\FolderIWantToAccess\\pic.bmp"
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
I tried it but the program still doesnt read the picture file...I want to access the pic.bmp without directly enforcing the complete filepath (e.g. c:\mydocuments\sample\project\folderiwanttoaccess\pic.bmp <--i dont want to write this in the program source file...)
|
|
|
|
|
I understand what you're trying to do.
You can access files in a higher directory level that the exe using "..\\". So if your .exe file is running from c:\mydocuments\sample\project\bin\debug\test.exe, you can locate the image from your C# code using
// Adjust the line below depending on how many parent directories must be navigated upwards to read the folderIWantAccessTo directory.
stromg pathToImage = "..\\..\\..\\folderIWantAccessTo\pic.bmp";
If you want to see what's going on with those "..\\" things, see what this returns:
string path = Path.GetFullPath("..\\..\\..\\");
It should return your project root. From there the rest is easy, just append the folderIWantAccessTo\pic.bmp to the end of the string and you're good.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
I figured out what was lacking in your idea... there should be three "." instead of two. It is now working correctly. Thanks very much
|
|
|
|
|
|
ei guys... i'm having a problem in printing the receipt for my point of sale. Just want to ask you... what tools should i used for the reciept and maybe some codes in printing it... thanks
|
|
|
|
|
Most printers are graphics printers. I have found that I can create class that builds the receipt as an image then send it to the printer. The api's are usually availiable from the mfg to configure the printer and they will give you examples.
I went this direction because getting text lined up is pretty difficult and in the end just looks bad.
|
|
|
|