|
Try drawing the line in the public void OnPaint(object sender, EventArgs e) event...
|
|
|
|
|
Hi,
I created a typed dataset, but the whole idea is that i want to return the XML information from it. I am using the getXML. This part works fine. What is not working is that there are times when not all the columns would be assigned, and if it is not assigned, it is not returning those tags. Is there a way to declare a default value when a new row is crated in a typed dataset. Thanks,
|
|
|
|
|
I have serialized an object from a project(lets name it x). When i deserialize it from the same project,i am able to recover my object.However, when i try to deserilize that object when i am working in another project, i get an exception " Assembly or file X missing " ?? Could someone tell me why??
Thanks.
|
|
|
|
|
when you serialize an object some information about the object is also saved. This includes the assembly to which the class belongs, the version, culture, the namespace etc. This information is required to recreate the class.
In your case the serializing is done in one assembly & deserializing in another assembly. The type information doesnt match.
One work around is to keep the class you want to serialize in a common assembly. and reference this asssembly in your other projects.
HTH
Rak
|
|
|
|
|
Thanks a lot. That was helpful.
|
|
|
|
|
Does anyone know ANY way of creating a DIB section in C#? I've spent the last few days trying every possible way of creating one. Whenever I call ::CreateDIBSection from the Win32 library, it fails, saying there isn't enough memory. However, after experimentation I realised that it does actually create one, but I can never successfully set the Pixel Format for it, I'm trying to create a pixel format suitable for OpenGL drawing, but it just doesnt work.
I'm using the correct settings for the pixel format, does anyone have any ideas?
Thanks in advance,
Dave
Dave Kerr
focus_business@hotmail.com
http://www.codechamber.com
|
|
|
|
|
I've created a custom control as follows (basic info):
Derives from System.Windows.Forms.Control
Styles set to(true): ResizeRedraw, AllPaintingInWmPaint, UserPaint, DoubleBuffer, SupportsTransparentBackColor, ContainerControl
In the OnPaint handler I draw the control out ...
When I change or set the Background color, it appears the control is being painted OUTSIDE the shape I have drawn (e.g., if I set the background color to Red, I can see a red rectangle with my custom shape drawn 'over it').
I realize this is some kind of region or clipping issue that I have not properly set ... I've been messing with the OnPaintBackground handler, but have not been able to overcome this issue.
Additionally, I have downloaded several custom drawn controls from CP and reviewed the code, and it appears that many of these controls suffer this same or similar problem.
As an overview, here's what I want to do: I am drawing a custom control that is an irregular shape (not a rectangle), that I want to be able to specify various background colors. The colors should (1) not bleed outside the bounding shape and (2) those edges beyond the outside of my control should be transparent when the control is layed over another object of a different color (if that makes sense).
This is my first custom C# control so I'm suffering a tad from lack of working knowledge with the framework and language (although thus far, it's not stopped me until now ... dang-it. )
TIA,
D.
|
|
|
|
|
I haven't done this before but maybe I can show you some point:
As I rememeber,I sets those styles in constructor of class after InitializeComponent().
There is an article in CP by Jibin Pan which create custom shapes for Form which title "Interactive Shaped Forms" in C# section .I don't have the link now but I copy/paste from it here,I guess the scenario is the same for UserControl too:
Create a form with some background color, then set the property TransparenceKey to that color and set the FormBorderStyle to None. You have to set these in the constructor of your UserControl
Override the Form_Paint function You can do it by
protected override void OnPaint(PaintEventArgs e)
or add a new Handler
this.Paint += new System.Windows.Form.PaintEventHandler(Form_Paint)
Using Region and GraphicsPath to set the Region that you want to display. im = new Bitmap("mediaPlayer.jpg");
private void Form_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle mainRect = new Rectangle(0, 0, 695, 278);
Region mainRegion = new Region(mainRect);
e.Graphics.SetClip(mainRegion, CombineMode.Replace);
// Create a GraphicsPath object and add a curve.
GraphicsPath myPath = new GraphicsPath();
...
Region ExcludeRegion3 = new Region(myPath);
e.Graphics.ExcludeClip(ExcludeRegion3);
...
e.Graphics.DrawImage(im, 0, 0, 495,278);
// Reset clipping region to infinite.
e.Graphics.ResetClip();
}
I don't know if you do the same in your pani event handler. Hope it helps.
Mazy
No sig. available now.
|
|
|
|
|
Mazy,
Thanks for the response ... I'll start messing with this later this evening. In the meantime, I have added code in my PaintBackground handler that shrinks rectangles down by a single pixel and paints those areas ... cheese but it works for the time ...
I will obviously have to implement a real solution prior to release of the control, so hopefully what you've provided here will kick me in the right direction ...
Thanks again,
D.
|
|
|
|
|
Hi have anybody heard bout any lead or tutorial or something aboout how to send and receive (mainly recieve) SMS (Short Message Service) in .NET.
So far I learned that I should implement the UCP protocol over IP.
Can anyone suggest me something that should ease my work?
Oh yeah I don't want to use any ActiveX or COM components, I want pure .NET.
modified 17-Oct-21 21:01pm.
|
|
|
|
|
does anyone know how to set the left margin when printing a textfile?
I have a form that prints to an Okidata 320 printer and the margin, by default, is set at 1". how can i set it to .5" on the Left margin only?
protected override void OnPrintPage(PrintPageEventArgs ev)<br />
{<br />
[other code here]<br />
<br />
float leftMargin = ev.MarginBounds.Left;<br />
<br />
[etc...]<br />
}
by the way, there is no way to set the margin on the okidata, nor can i move the form any farther to the right to fix this. it has to be done in the code.
thanks.
.gonad.
|
|
|
|
|
thank the Lord no one responded to this, because i feel really stupid.
i just divided the margin by 2 to get .5".
float leftMargin = ev.MarginBounds.Left / 2;
Thanks!
.gonad.
|
|
|
|
|
I currently have a project which requires me to build a sudo textcontrol. The things, I need to do can't be down with a normal textcontrol. Currently, I've started implementing a basic textcontrol from a picturebox.
I need to be able to do the following
* Implement a cursor
* select existing text
* Cut & Paste
Are there any online references ?
Has anyone done this before?
Any tips?
Thanks
Kevin
Kevin Fowlks
Programmer Analyst
Michigan State University
Center for Remote Sensing & GIS
|
|
|
|
|
after creating setup file by package and deployment wizard when i going to install that setup file on a machine where .net runtime not installed i got error. so i want to full instruction how to create a setup file i .net that will run on a machine where .net runtime not there.
tbhattacharjee
|
|
|
|
|
Out of curiosity, are you using VS2002 or VS2003? My colleagues tell me that VS2003 will prompt to download the .NET runtime if necessary. I haven't been able to test that on a virgin machine.
|
|
|
|
|
Hi,
I recently had to build a installation program to install my application and I tried to do it using the "Deployment" project in Visual Studio.Net. After much research and help from the folks on this message board I was able to build the installation package.
There are 2 things to be done:
1. Create a new project of type "Deployment" and add all the components of your application to this project. You can specify the folders they need to be on the target computer, the icons/shortcuts on the desktop, the item in the Start->Program Menu, etc.
On building this project it will generate a .wsi file, a setup.exe along with other files. All the files generated in the Debug directory constitute the installation package.
The above package will run perfectly on any computer as long as it has .NET framework installed on it. If not then you have do the second thing.
2. Download the BootStrapper sample from the following link:
http://www.microsoft.com/downloads/details.aspx?FamilyId=BF253CFD-1EFC-4FC5-BA7E-6A6F21403495&displaylang=en
Its in unmanaged C++. Build it and it will generate a setup.exe. It also has a settings.ini file.
Copy the setup.exe and settings.ini into a folder, say, myfolder. Then copy the .wsi generated in step 1 above into myfolder. Then copy the dotnetfx.exe (the .net framework installer) into myfolder.
The dotnetfx.exe can be downloaded from here:
http://www.microsoft.com/downloads/details.aspx?FamilyId=D7158DEE-A83F-4E21-B05A-009D06457787&displaylang=en
All files in myfolder now constitute your new installation package. This installation will first check if .NET is installed or not on the target computer, if not, then it will silently install it and then it will install your application.
I hope this helps.
Suhas
Those who can, do, those who cannot, teach.
|
|
|
|
|
Visual studio .net Installer it’s an useful ( and free J ) tool to deploy for project, but... there is a problem, what if your client doesn’t have installed the “.net framework”, to make your application able to be installed on any machine, the guys from Microsoft made one sample, look at this in the msdn page:
Microsoft .NET Framework Setup.exe Bootstrapper Sample
|
|
|
|
|
say suppose i am working with few controls and in a control collection loop i want to show the each control name,caption and control type.if it is possible in c# then please tell me with sample code.
tbhattacharjee
|
|
|
|
|
foreach(Control c in this.Controls)
{
MssageBox.Show(c.GetType().ToString());
MssageBox.Show(c.Name);
}
Mazy
No sig. available now.
|
|
|
|
|
Say suppose i have five button on a form and i want to trap click event for all five button in single event procedure.how could i do it please explian me with code example...
tbhattacharjee
|
|
|
|
|
if I understand correctly you have 5 buttons on a form and regardless of which one the user clicks you want the same event handler to be fired.
There are a couple of ways of doing this and it all depends on what your personal coding preference is.
Method 1
Create your 5 buttons and then in code allocate the same handler to the event.
E.G.
this.button1.Click += new System.EventHandler(this.5buttonEvent_Click);
this.button2.Click += new System.EventHandler(this.5buttonEvent_Click);
this.button3.Click += new System.EventHandler(this.5buttonEvent_Click);
this.button4.Click += new System.EventHandler(this.5buttonEvent_Click);
this.button5.Click += new System.EventHandler(this.5buttonEvent_Click);
Method 2
Allocate different event handlers to each of the buttons, and in each event call the same piece of code
e.g.
private void button1_Click(object sender, System.EventArgs e)
{
DoEvent(sender, e)
}
private void button2_Click(object sender, System.EventArgs e)
{
DoEvent(sender, e)
}
Repeat for button3, 4 & 5
void DoEvent(object sender, System.EventArgs e)
{
}
There are probably a few other ways of doing this, I personally would go for method one as it uses less code.
|
|
|
|
|
I have installed IIS in my winXp,and i built a asp.net web service ,It compile Ok,but when run debug,It hint a error(It tool difcult for me to understand ) and I must disable debug,how i do to solve this problem?
|
|
|
|
|
I have a struct to mimic a c++ struct...I have converted types as follows:
C++ C#
---- ----
WORD ushort
DWORD uint
char[] string
the imported function passes a pointer to the struct, fills it with fun-facts and gives it back more useful than before. The only thing I currently want out of this is the char[] member of the struct and things are not working out.
Here's what I have done:
- I am using CharSet.Auto in the structLayout and dllImport attributes.
- in the function prototype : "ref STRUCTTYPE structname"
- before calling the function, initializing struct by using "new"
- before calling the function, initializing the string by creating a StringBuilder buffer of appropriate size and "ToString-ing" it to the struct.string member.
problem is, when I call the function and access the string, it still contains the text that I used to initialize it in the first place.
I haven't done enough testing to determine the problem, but I wanted to see if you have any ideas. My first question is to verify that using a c# string to represent the c++ char[] is all cool. I think it should be.
[Edit] Almost, need [MarshalAs(UnmanagedType.ByValTStr, SizeConst=256] because it is a fixed char array [/Edit]
What I was thinking of while typing right now, is this:
in c++ structs are reference variables. in c# they are value variables. if i wanted to pass a c# struct to a c++ function, i would use the ref modifyer. Since my function wants a pointer to the struct, should I be using something like "ref IntPtr structname" ???? is this my problem and my solution?
[Edit] not quite, should work with "ref STRUCTTYPE structname"... if the struct were represented using a class, then would need [In,Out] instead of ref. See link in next post for details. Can't wait to get home and try it![/Edit]
Tym!
|
|
|
|
|
|
How can I make a ListView editable?
The LabelEdit property doesn't work with columns, when I double click a subitem just edit the first subitem, not the one I actually double clicked.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|