|
tatarrullaz wrote: just graduated
You should go right back to school. I'd written more constructors than I can count before I even started my first year at university. You have no excuse.
|
|
|
|
|
You can just simply write a custom property method for that.
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
you mean a public class that can be reached from the new form?
is this it?
|
|
|
|
|
Yes, but it depends on how you are going to use the class... you can also use a constructor.
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
That would be awful IMHO if all you need is to send selected item. You should used a parameterized constructor. Or have a public event handler so that you can handle the double click event in the Form where you need to get the selected value.
Constructor would be the simplest way though.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
class Form2 {
private string m_Data;
internal Form2(string data) {
m_Data = data;
}
private void Form2_Load(...) {
Use m_Data here........
}
}
class Form1 {
private void ListBox1_DoubleClick(...) {
Form2 f2 = new Form2(ListBox1.SelectedText);
f2.Show();
}
}
|
|
|
|
|
"Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime"
Same goes for code.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You are right. Until they know what a fish is, we have to give them fish
|
|
|
|
|
No, you missed the point. We don't give them the code, we teach them to code.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
SelectedObject = GetSelectedObjectFromListBox();<br />
MyPopUpForm form = new MyPopUpForm();<br />
form.SelectedObject = SelectedObject;<br />
form.Show();
or
SelectedObject = GetSelectedObjectFromListBox();<br />
MyPopUpForm form = new MyPopUpForm(SelectedObject );<br />
form.Show();
depending on your preference.
In the 1st case you need a public property in your popup form, called SelectedObject. In the setter, you need to do what you need to do.
In the 2nd case you need a constructor that takes a SelectedObject as a parameter. It is usually inadvisable to use this constructor to populate your form - store it then populate when the form is shown.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
I'm trying to figure out how to tell if a feature is install on Vista SP1 and newer OSs. does anyone know where this is stored at?
i need to check if the Group policy management features are installed, it is not listed in the registry for add remove programs...
thanks
|
|
|
|
|
Hi
In codebehind i want to know when my checkbox become unchecked?
|
|
|
|
|
The documentation will be able to show you how to do this, but you can check using
if (checkbox1.checked == true)
else
Also, make sure to check that your checkbox is not a three-state checkbox.
Clickity[^]
Also, make sure to use Liquid Nitrogen properly next time.
|
|
|
|
|
No;
I need an event that occur when a checkbox become unchecked;
|
|
|
|
|
Well... you can create the event anonymously using
checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
Or you can have visual studio add the event and delegate for you by (through designer) selecting a checkbox on your form, going to its events and double clicking the CheckChanged property. This will, like all other events added through this method, create the event handler for you in the designer file and create a method stub for you.
Or you can add the delegate and event handler yourself using the code above...
|
|
|
|
|
If you are talking about ASP.NET, you need to set the AutoPostback property of the CheckBox to true and then handle the CheckedChanged event.
|
|
|
|
|
I work in windows application
|
|
|
|
|
I already told you how to do this above.
|
|
|
|
|
I agree with you...
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
farokhian wrote: In codebehind
Does this mean you meant to post in the ASP.NET forum ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I find when most beginners say 'codebehind' they usually are talking about the designer file. Quite to common for my liking.
|
|
|
|
|
Hello guys and girls
I'm recently started on C# but as I know abit programming (Coming from Java) it should be easy to do this, but as I have experienced from Microsoft its never easy on customizing or subclassing their components (I've tried in Win32/C Old school, but thats many years ago)
The question is:
I want to draw a dropshadowborder on a panel and/or take it further to draw all components with a dropshadow when they are added to the panel
I started on subclassing Panel to override OnPaint, but as I cannot do the following code (atleast not yet) in C# I would like to have an explanation if you guys/girls are up for it or willing to help me out so I learn abit more this day
// Sample code working in Java
@Override
public void paint(Graphics g) {
if (shadow == null) {
BufferedImage buffer = new BufferedImage(getWidth(),
getHeight(),
BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = buffer.createGraphics();
super.paint(g2);
shadow = factory.createShadow(buffer);
g2.dispose();
g.drawImage(shadow, distance_x, distance_y, null);
g.drawImage(buffer, 0, 0, null);
} else if (isVisible()) {
g.drawImage(shadow, distance_x, distance_y, null);
super.paint(g);
}
}
// End of sample snippet
My snippet in C#:
//Snippet from C#
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
Image buffer = new Bitmap(Width, Height);
Graphics g2 = Graphics.FromImage(buffer);
g2.FillRectangle(new SolidBrush(Color.Black), new Rectangle(5, 5, Width, Height));
e.Graphics.DrawImage(buffer, 0, 0);
}
I know the code convertion isnt exact the same but it was to point out my problem
I hope you can see what I want to do, and I hope someone is willing to spend some minutes answering me with some theory.
My Best Regards and Wishes
David Bundgaard
|
|
|
|
|
The control has a method that causes it to render itself to a bitmap. It's called DrawToBitmap. Use that to create a copy of your control in a bitmap, then you can manipulate it.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi, If I use a using command that uses a oleDbCommand object, do I need to close the using statement before I return a result?
eg
using (OleDbCommand Command = GetCommandObj("DB1"))
{
Command.CommandText = "<sql statement>";
return Command.ExecuteScalar().ToString();
}
will the above code dispose of the OleDbCommand and release the connection?
or do I need to do somethiong like:
string result = string.Empty;
using (OleDbCommand Command = GetCommandObj("DB1"))
{
Command.CommandText = "<sql statement>";
result = Command.ExecuteScalar().ToString();
}
return result;
also, should I include something like
Command.Connection.Dispose(); within the using statement to release the connection?
Thanks,
Chas
|
|
|
|
|
Yeah, I think that's in the documentation.
|
|
|
|