|
In the link label click handler
void myLinkLabel_Click(object sender, EventArgs e)
{
Form2 myForm2 = new Form2();
myForm2.Text = myLinkLabel.Text;
myForm2.Show();
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
i tryed that, that happens to be the first thing i tryed
this is my linkLabel code
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
ItemsForm VIF = new ItemsForm();
VIF.ShowDialog();
}
and this is the error i get when i input ItemsForm.Text = linkLabel1.Text
An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Text
also the linkLabel name will be givin when the other parts of the program are activated such as the two listBoxes and radioButtons
Thanks.
|
|
|
|
|
Text is an instance property, not a static one - so you set Text on the instance that you created which was called VIF
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
ItemsForm VIF = new ItemsForm();
VIF.Text = linkLabel1.Text;
VIF.ShowDialog();
}
|
|
|
|
|
Thank you, i have tryed many ways and that is so simple i can not belive i did not find that.
thank you again.
|
|
|
|
|
ItemsForm.Text is trying to set a static property called text. You can only set the text on an instance of your ItemsForm.
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
ItemsForm VIF = new ItemsForm();
VIF.Text = linkLabel1.Text; // This will work, because you're setting the text of an ItemsForm instance, rather than on the ItemsForm class itself
VIF.ShowDialog();
}
|
|
|
|
|
Hi,
Anyone know why I'd get this error?
The type or namespace name 'CollectionEditor' could not be found (are you missing a using directive or an assembly reference?)
I do have using System.ComponentModel.Design; and then
private class CustomTableStylesCollectionEditor : CollectionEditor<br />
{<br />
public CustomTableStylesCollectionEditor(Type type):base(type)<br />
{<br />
} <br />
...<br />
} <br />
Thanks again!!!
Mel
|
|
|
|
|
melanieab wrote: Anyone know why I'd get this error?
The type or namespace name 'CollectionEditor' could not be found (are you missing a using directive or an assembly reference?)
You have to add a reference to System.Design.dll too.
Share and enjoy.
Sean
|
|
|
|
|
Thanks!!!!
Mel
|
|
|
|
|
Hi all,
I have a table which is having one datetime column. I try to retrieve values from the table in SP along with the mentioned datetime column value.
When i Run the query in analyser it works fine ( i expect the datetime column should return datetime with Millisecond and not with AM PM ) in query analyzer.
WHen i asssign the same values to a property in the middle tier, the millisecond values got truncated and the AM/PM comes into picture. ( i tried to have the property as string not datetime , it doesnt work ] .
Any help that how can i retrieve and assign a datetime column value with millisecond and not with AM/PM in C#.
code snippet please!
Happy coding!!
kotteeswaran
|
|
|
|
|
The problem is not where you think it is. A DateTime value does not have a format, so it can't have an AM/PM indicator. It's when you convert the value into a string that it gets it's format. If you specify a format where the milliseconds are visible, you will see that they are there.
---
b { font-weight: normal; }
|
|
|
|
|
Can you connect to an Oracle Database when the form loads without executing a query? I would like to connect to the db first when the form loads and have a static connection while the application is running. When the user clicks a button, it simply performs a query and does not have to connect.
Any suggestions?
Thank you!
Apoc
|
|
|
|
|
Yeah, don't do it.
It's considered very bad practice to grab a very expensive connection license and hang on to it when your app isn't doing anything. Connect, query, release. It's that simple. There's almost never a good reason to hold onto a connection to the database for the life of your application.
Think of it this way. If you have 100 people using your app, but only half of them are doing any database work at any one time, do you want to spend $15,000 for 100 connection licenses or $7,500 for 50?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yea your right...
I fiqured out that the query was taking a long time and not the connection.
Thanks for the input!
Apoc
|
|
|
|
|
Hello,
I have a TextBox and a ListBox controls. I want to raise KeyDown event of the ListBox when user presses Up or Down Arrow keys from keyboard, on the TextBox.
How can I send the Keycode (key stroke) that user just pressed, to my ListBox from within KeyDown event of my TextBox?
Thanks,
Baris.
|
|
|
|
|
The best way to do this is to inherit a control from ListBox or TextBox, then call the protected method OnKeyDown. There are other ways as well, such as using SendKeys (not recommended, as it makes use of hooks, which can be blocked by certain anti-virus applications), or using the Win32 PostMessage.
I'd recommend inheriting from the control and calling OnKeyDown to artificially raise the event.
|
|
|
|
|
Aren't there any more easy way to do this?
If not, how can I inherit? Note that I want to use this new control at design-time. In other words, I must see the new control on my palette (Toolbox). And it must be like the list box exclude new method: MyKeyDown which I can call it from within any where of my code.
Thank you very much,
Baris
Notice: I am new to .Net and C#.
|
|
|
|
|
Inheriting is easy to do. Just create a class like this:
public class MyListBox : ListBox
{
...
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
}
public void FireKeyDownEvent(Keys pressedKeys)
{
OnKeyDown(new KeyEventArgs(pressedKeys);
}
}
As far as adding your control to the toolbox, you should be able to do it just by adding new item to toolbox, and when it asks you for the item, have it point to your dll containing MyListBox. I recommend you look at some of the articles here at Codeproject on how to design a good custom control fit for the toolbox.
|
|
|
|
|
badidi wrote: Aren't there any more easy way to do this?
You could also try using reflection to call the protected member on the control you want to access.
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
What is reflection? Can you give an example?
Baris
|
|
|
|
|
I don't want only raising event. Also I want to make an effect to list box as if user pressed the down arrow key on it for example.
Baris
|
|
|
|
|
Hi i am having some trouble tryin to make sure the users of my web app (which im writin in c#) enter the correct types of data in the fields is ther someway to check if the data entered is a string when it should be and a number when it should be without doing a postback to the server, any ideas
Thanks in advance
|
|
|
|
|
|
Hello there,
I did Com+ component has many class all classes marked with autocomplet , Guid and some required and other requiredNew when i am trying to call methods from one of these classes it prombet me with this message
"The transaction has already been implicitly or explicitly committed or aborted
"
Please i need to know what dose it means this message.
Thanks for your time and help
Best regards,
Hoho
|
|
|
|
|
It means exactly what it says. You are trying to use a transaction that is no longer in use.
To tell you anything more than that, you have to provide some information on what you are trying to do.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for your reply
I am trying to do some operations on the Sql database with this com+ like insert, update and delete but this operations works with transactions
Thanks
Hoho
|
|
|
|