|
It was a question about validating input without the postback using JavaScript and it was pointed out that this wasn't the best place to ask this question. I'm not psychic; the OP removed the question, but couldn't delete it since there was a reply to it.
|
|
|
|
|
Hi All
Is it Possible to Call A Function Like This to add a link label to a particular form
public void AddLinklabel(string form,int top, int left, int width, int height,string Link)
{
LinkLabel linkLabel1 = new LinkLabel();
form.linkLabel1.Location = new System.Drawing.Point(top, left);
form.linkLabel1.Size = new System.Drawing.Size(width, height);
form.linkLabel1.AutoSize = true;
}
If Possible Please Show Me A Example Code
Please Help Me
Arunkumar.T
-------------------------
p4,3ghz,hdd-500gb,ram-4gb
|
|
|
|
|
Why not convert your method into a generic method? BTW, please enclose code samples in pre blocks like this:
public void AddLinkLabel<T>(T containingForm, int top, int left, int width, int height, string link) where T : Form
{
LinkLabel label = new LinkLabel();
label.Location = new System.Drawing.Point(top, left);
label.Size = new System.Drawing.Size(width, height);
containingForm.Controls.Add(label);
} Note that I've just typed this sample into this textbox, so there might be an error or two, you should be able to get the gist from this though.
|
|
|
|
|
I Called The Function Like This But There are lot of errors displaying
Error 1 The type 'string' must be convertible to 'System.Windows.Forms.Form' in order to use it as parameter 'T' in the generic type or method 'WindowsApplication1.Form1.AddLinkLabel<T>(T, int, int, int, int, string)' C:\Documents and Settings\Agni\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs 21 13 WindowsApplication1
AddLinkLabel("Form1", 20, 20, 100, 30, "Click Here");
is there any other method to call this function?
|
|
|
|
|
Of course you've got errors, you've given it a string in place of the form instance. You'd need to give it like this:
AddLinkLabel(myFormInstance, 20, 20, 100, 30, "Click here"); BTW - why did you not encode your code in C#? I told you to do it before.
|
|
|
|
|
Thankyou This Time I Dont Get Any Errors The Program Executed Well But I Cant See The Label I Created
And Also How Can I fire Click Event? And Where Should I Add The Url?
This is My Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Form1 frm1=new Form1();
AddLinkLabel(frm1, 20, 20, 100, 30, "Click Here");
}
public void AddLinkLabel<T>(T containingForm, int top, int left, int width, int height, string link) where T : Form
{
LinkLabel label = new LinkLabel();
label.Location = new System.Drawing.Point(top, left);
label.Size = new System.Drawing.Size(width, height);
containingForm.Controls.Add(label);
}
}
}
|
|
|
|
|
You don't need to create a new instance of Form1. In fact, as you have placed this method inside your Form class, you don't even need containingForm, but assuming you are going to move this method into a separate class, your call to AddLinkLabel would look like this:
AddLinkLabel(this, 20, 20, 100, 30, "Click Here"); You have now added the link label to the controls collection of the form that's displayed (and not the form you instantiated in Form1 frm = new Form1(); .
|
|
|
|
|
Thankyou For That It Work on a form load event
I Writed The Same Code to A Class File To Create a library for link label but it faild there are so many errors displaying
this is my class library code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Net;
using System.Windows.Forms;
namespace linklabel
{
public class LinkLabel
{
public void AddLinkLabel<T>(T containingForm, int top, int left, int width, int height, string Text, string link) where T : Form
{
LinkLabel label = new LinkLabel();
label.Location = new System.Drawing.Point(top, left);
label.Size = new System.Drawing.Size(width, height);
label.Text = Text;
containingForm.Controls.Add(label);
}
}
}
is it possible to create a library for a control?
|
|
|
|
|
Arunkumar.Koloth wrote: is it possible to create a library for a control?
Yes, but you have to remember to add the right references to the class library. Here's a hint for you for the future; when I want to create a library for a forms application like this I would normally create it as a windows forms application, remove the generated forms, and change the output type to class library. By doing this, I've got all the basic references that I need.
From this answer, you can tell that what you need to do is add in the missing references. Good luck
|
|
|
|
|
|
|
Hello ,
I would like to ask if its possible to compile a project (for example a win.form projet) so that for example one of the directories in it (lets call it library.dir) would compile to dll . So the output would be a startable exe with library at the same location . Dunno if this is possible but it would help me alot ! Thanks in advance ! (Using MVS 2010)
|
|
|
|
|
You can split your classes out into different projects. Each project will compile to its own file (for example, EXE or DLL).
|
|
|
|
|
Your post doesn't make any sense, but a single project can compile only to a single type of output. You cannot compile a class library into both a .DLL and .EXE output. You can only do one at a time.
Now, it is possible to add a second project that will use the .DLL project as a reference and can be saved to the same folder as the .DLL project. Then you can compile the entire solution (both projects) and get both the .DLL and .EXE outputs.
This is a bit of a paint to configure and maintain so I'm wondering what the motivation is behind this?
|
|
|
|
|
I m trying to find a good way to maintain my project the easyest way . Since i know i only will need to update the DLL (we ll mutch more than the actual .exe) i wanted to do it somehow "smart" but since its like this ... nwm . Thanks for your time guys .
|
|
|
|
|
In future, try to reply to the people who answered you, instead of your own message. That way they get an email. If you reply to your own message as you did here, nobody does.
It speeds things up as people don't have to check back to see if there are any updates.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Oh god i m so sorry. Didnt know it since i m new here . Thanks for the typ !
|
|
|
|
|
No problem!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Didn't know why this was downvoted even if the advice makes sense. Voted 5.
Ignorance of the ability brings disability.
|
|
|
|
|
how can i convert ascii (1633) : "1" to int?
it make "unexpected character" exception.
|
|
|
|
|
What code have you tried?
|
|
|
|
|
ASCII is a 7-bit character set, its values range from 0 up to 127.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
"1", "6", "3", and "3" are all ASCII characters. Still, I suspect, as I suspect you suspect, that the OP meant to say "string" rather than "ASCII".
|
|
|
|
|
Actually, I am confused why the OP mentions 1633 and then "1".
|
|
|
|
|
So his confusion is contagious, is that what you are saying?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|