|
hi
i have a pictureBox that show my .gif image on the form.
i want to change transparency of my .gif image but how to do ?
thanks
|
|
|
|
|
I believe to do that, you have to draw it on your form yourself. I don't know that a picture box can draw transparently. I may be wrong
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I think all controls have the ability to draw transparently, but in some cases you have set something before it will actually do it. I don't quite remember.
Transparency isn't so great in .Net, it works by the control getting its parent to draw its background for it, so if you had another control behind it, it wouldn't show through.
Infact, it may only get the background colour of the parent and use that... i'm not entirly sure.
My current favourite word is: PIE!
I have changed my name to my regular internet alias. But don't let the 'Genius' part fool you, you don't know what 'SK' stands for.
-The Undefeated
|
|
|
|
|
Anyway... i think you will have to draw it yourself, which is quite simple really. But if you do end up drawing it yourself, it may be easier to just have a panel and use the OnPaint event for that, rather than using a picture box.
My current favourite word is: PIE!
I have changed my name to my regular internet alias. But don't let the 'Genius' part fool you, you don't know what 'SK' stands for.
-The Undefeated
|
|
|
|
|
You need to have an alpha channel in the image. I don't GIF files have it, but PNG files do.
Unfortunately the transparency only goes to the form, any controls underneath the picturebox will not be visible.
Mike
|
|
|
|
|
I have a thread which is called when a user is typing,
But if you type really fast (key smash style) it will crash becuase the datareader is already opened.
I dont actually have a declared datareader but i assume that the data adapter does that himself so i can preclose it since i cant get to its properties.
So instead i was thinking of catching the expection and rerunning the code but how do i goto the start of the thread again?
filterthread = new Thread(new ThreadStart(opg_filter_functie));
filterthread.IsBackground = true;
filterthread.Start();
private void opg_filter_functie()
{
//check if textbox isnt empty
if (opg_filterbox.Text.Length > 0)
{
try
{
opg_tv_filter.Nodes.Clear();
//sql injection causes error fix
opg_filterbox.Text = opg_filterbox.Text.Replace("'", "");
//create query
SqlDataAdapter dAdapter = new SqlDataAdapter("SELECT artiestNaam FROM artiest where artiestnaam like '" + opg_filterbox.Text + "%'" ,sqlcon);
DataSet dataset_filter = new DataSet();
dAdapter.Fill(dataset_filter); //crash here if typing to fast
|
|
|
|
|
Why not add a locker to force the method to never execute more than once at a time? All you need is a locker object:
<br />
object locker = new object();<br />
private void opg_filter_functie()<br />
{<br />
lock(locker) {<br />
if (opg_filterbox.Text.Length > 0)<br />
{<br />
try<br />
{<br />
opg_tv_filter.Nodes.Clear();<br />
opg_filterbox.Text = opg_filterbox.Text.Replace("'", "");<br />
<br />
SqlDataAdapter dAdapter = new SqlDataAdapter("SELECT artiestNaam FROM artiest where artiestnaam like '" + opg_filterbox.Text + "%'" ,sqlcon);<br />
DataSet dataset_filter = new DataSet();<br />
<br />
<br />
dAdapter.Fill(dataset_filter);
}
Standards are great! Everybody should have one!
|
|
|
|
|
Hai how can we write the generic list to excel file using C# can any one help in this
|
|
|
|
|
Well, that the data is in a list, is totally irrelevant. You can write a cvs, which excel can open, or you can control Office via the tools for office, and make it create an Excel file for you
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi
I have a C# app that embeds another app inside of it using setparent win32 API however the embedded application launches other Child applications that check if the parent is running by using FindWindow with a Class name of “MyWndClass”.
The solution would seem to be to set the Class name of my app to “MyWndClass” but I can only find reference on how to do this using C++ using PreCreateWindow().
So how can I do this from C#?
|
|
|
|
|
I have a MenuStrip with a number of ToolStripMenuItems
I'm trying to show a context menu when they are right-clicked so on the MouseUp-event I add
private void presetItem_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
presetMenu.Show(Cursor.Position);
}
}
This works but the menu I right-clicked closes when the context-menu shows up.
Can I prevent the menu from closing somehow?
|
|
|
|
|
That's default behavior.
i think you need to make your own control that derives from ToolStrimMenuItem and in that override accordingly
|
|
|
|
|
Ok, Thanks... I will try and come with something
|
|
|
|
|
How to generate excel sheet in aspx page in c#.Net
suman.C
|
|
|
|
|
You can't - nothing that is specific to an ASPX is going to interact with Excel. You can write C# code that generates an Excel file, and then save it and push it down to the browser, if that's what you want to do.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello again
I have two forms, one being opened by another.
What I want to do is that the second form that is opened by the first one is when it is closing, I want it to run a method in first form.
The code I used is something like this.
private void frmAddCategory_FormClosed(object sender, FormClosedEventArgs e)<br />
{<br />
frmCore core = new frmCore();<br />
core.comboRefresh("newPost");<br />
<br />
<br />
}
It doesnt work. I checked with debug and it seems to run, but nothing seems to happens to the first form.
Its a dropdownlist that has items in it, the second form adds new items to it in a database.
the method that is called is taking data from a database and updates the dropdownlist with the new items.
|
|
|
|
|
ah those vb programmers
frmCore core = new frmCore(); creates a new instance of your mainform. so calling a method on this new instance will not affect the first form.
i wouldn't do it like this anyway.
my preferred solution for such things is this:
public class frmAddCategory:Form
{
public string NewPost
{
get
{
return txtNewPost.Text;
}
}
}
public class frmCore:Form
{
private void SomeButton_Click(object sender, EventArgs e)
{
frmAddCategory blah = new frmAddCategory();
if (blah.ShowDialog() == DialogResult.OK)
{
myComboBox.Items.Add(blah.NewPost);
}
}
}
greets
M@u
|
|
|
|
|
m@u wrote:
public class frmAddCategory:Form
{
public string NewPost
{
get
{
return txtNewPost.Text;
}
}
}
public class frmCore:Form
{
private void SomeButton_Click(object sender, EventArgs e)
{
frmAddCategory blah = new frmAddCategory();
if (blah.ShowDialog() == DialogResult.OK)
{
myComboBox.Items.Add(blah.NewPost);
}
}
}
What is this ? This looks totally out of topic to me !
|
|
|
|
|
Im not a VB coder, but I guess I use their method or something like that
Anyway. It looks like it pass a value to a variable to the first form, which isnt what I wanted to do. I wanted to call a method. But maybe a similiar way to do like you stated above.
Can you show me some sample code to call a method (function, procedure, whatever :P)
|
|
|
|
|
sorry i thought you want to pass a value entered in frmAddCategory.
for calling a method, like navaneeth says, a delegate/event would be appropriate:
public class frmAddCategory
{
public event EventHandler CategoryAdded;
protected virtual void onCategoryAdded(EventHandler e)
{
if (CategoryAdded != null)
{
CategoryAdded(this,e);
}
}
private void someEventHandler(...)
{
onCategoryAdded(EventArgs.Empty);
}
}
in the calling Form after creating frmAddCategory say
myForm.CategoryAdded += new EventHandler(myForm_CategoryAdded);
and in the myForm_CategoryAdded you can then add the Entry to the Combobox.
|
|
|
|
|
Deques wrote: frmCore core = new frmCore();
This will create a new instance for the form and method in that instance will be called.
I prefer to use delegates in this scenario. Create delegate in second form and hook a method handler from first form when second form is invoked. On second forms FormClosed event, invoke this delegate.
Hope it helps
|
|
|
|
|
How does it work? I am not familiar with delegates >.<
Could you provide me some code examples, please?
|
|
|
|
|
|
Deques wrote: I am not familiar with delegates
Delegates are function pointers in which you can assign a function's reference, and when delegate is invoked, supplied function will be called.
For explaining this we have two forms say Form1 and Form2 . I am invoking Form2 from Form1's load event. Inside Form2 I have declared a delegate. See the Form2 code below
public class Form2 : System.Windows.Forms.Form
{
public delegate void FormClosed();
public FormClosed FormClosedHandler;
private void Form2_Closed(object sender, System.EventArgs e)
{
FormClosedHandler();
}
} In the above code, you can see I have created a FormClosed() delegate and an object for that delegate. This object I will be assigning from the Form1 just before Form2 is shown. See the Form1 code below
public class Form1 : System.Windows.Forms.Form
{
private void Form1_Load(object sender, System.EventArgs e)
{
Form2 obj = new Form2();
obj.FormClosedHandler += new Form2.FormClosed(this.Form2ClosedHandler);
obj.Show();
}
} In this I have assigned a private method Form2ClosedHandler to the delegate. So when delegate is invoked, this private method in Form1 will get called. You can refresh your combo inside this method.
Delegates are good for communicating between classes.
Hope this helps
|
|
|
|
|
Thanks for the information
I have tried this code, but when I build it I get this error the private method I have assigned with. I thnk I have done something wrong
It says "Method name expected"
This is the code I used for form 1
private void btnNewPost_Click(object sender, EventArgs e)
{
Forms.frmAddCategory addcats = new frmAddCategory();
addcats.Refresher += new Forms.frmAddCategory.refreshcat(this.comboRefresh("newPost"));
addcats.ShowDialog();
}
comboRefresh(string blah)
{
}
and this is for the form 2
public partial class frmAddCategory : Form
{
public delegate void refreshcat();
public refreshcat Refresher;
private void frmAddCategory_FormClosed(object sender, FormClosedEventArgs e)
{
Refresher();
}
|
|
|
|