|
Looking at your code, the problem appears to be with the frm.Focus(); line:
- You create a new instance of the form type;
- You check to see if there is an open form of the same type;
- If there is, you call the
Focus method on the new form instance;
I suspect that calling Focus on an invisible form causes it to be shown.
Try something like this instead:
private Form FindOpenFormOfType(Type formType)
{
foreach (Form form in Application.OpenForms)
{
if (form.GetType() == formType)
{
return form;
}
}
return null;
}
private void klikMenu(object sender, EventArgs e)
{
string sFormName = "AIO_System." + ((ToolStripMenuItem)sender).Tag.ToString();
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
Type formType = asm.GetType(sFormName);
Form frm = FindOpenFormOfType(formType);
if (frm == null)
{
frm = (Form)Activator.CreateInstance(formType);
frm.Owner = this;
frm.Show();
}
else
{
frm.Focus();
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: I suspect that calling Focus on an invisible form causes it to be shown. In Windows Forms calling 'Focus on an instantiated, but hidden, Form will not cause it become visible.
Your code would work "as is" if you removed the modifier ".Tag" in the line where 'sFormName is constructed ... but, we can't know, from the information the OP presented, what they've done to create a 'Tag property for the ToolStripMenuItems ... that's not shown in the code posted here.
“The best hope is that one of these days the Ground will get disgusted enough just to walk away ~ leaving people with nothing more to stand ON than what they have so bloody well stood FOR up to now.” Kenneth Patchen, Poet
|
|
|
|
|
if(frm != null)
{
MessageBox.Show("already running");
}
|
|
|
|
|
I have added a new column to my database table. When I have added this new columnm, the first chance exception start appearing. When I debugged it, it stated the code line
MLongListSelector.ItemsSource = c.ToDoList.ToList(); is the next statement to execute that causes the problem. What have I done wrong there?
using (DatabaseContext c = new DatabaseContext(DatabaseContext.ConnectionString))
{
c.CreateIfNotExists();
c.LogDebug = true;
//output todolist data from database
MLongListSelector.ItemsSource = c.ToDoList.ToList();
}
|
|
|
|
|
Check the column name and connection to database
|
|
|
|
|
I have finally solved it . There was a problem in creating the database. instead of CreateIfNotExist() i used If(!DatabaseExist()){CreateDatabase();}
This solved it. It doesn't really make sense to me as it is actually the same thing. But it works.
|
|
|
|
|
Hi Guys,
Ive just finished my admin panel that uses an SQL source and fills a list view with all clients and allows admins to update, edit Customer details..
Im trying to do the same thing for my User Panel (after user logs in and wants to edit their information)
Im using Context.User.Identity.Name(page_Load) in a label to welcome the user (can I SELECT the value from here??)
I don't want all the customer details coming up, just the ones for that particular user.
Is it possible to display only the customer information for the Current user? and again just in a simple listview
Any help is appreciated,
any questions, just ask.
|
|
|
|
|
Unless I'm misunderstanding, would a simple WHERE clause allow you to limit the returned Customer details for just that customer whose username is Context.User.Identity.Name ?
/ravi
|
|
|
|
|
I'v inherited ComboBox in C#.net winform , and I'v drew a rectangle's diagonal(like 'X') behind the content of each item in the override method OnDrawItem . Now I want to implement a function, when mouse click the area of rectangle can delete current item , rather than to select the current item.
Anyone can help, Thank y:confusedou very much!
Denny Xue
|
|
|
|
|
|
Unfortunately, that MSDN example code (all too typical of the so often valueless, poorly written, code samples on MSDN) does only one thing: it automatically removes all instances of ComboBoxItems with the same (string) value: an off-topic digression in terms of illustrating what the SelectedIndexChanged Event is about.
In the "real-world," you would filter your ComboBox Items in some way (via Linq 'Distinct if you were data binding, etc.) so you prevented duplicates. I suppose, in some exotic case one would allow duplicates, but I have yet to see that.
In this case, the OP wants to remove a ComboBoxItem only if the the end-user clicks on a special owner-drawn area of the ComboBoxItem. We don't know if the OP "allows" duplicate items, or wishes to remove duplicate ComboBoxItems.
Forgive me if I sound like I'm displacing anti-MSDN-doc-fervor ... onto you ... please
“The best hope is that one of these days the Ground will get disgusted enough just to walk away ~ leaving people with nothing more to stand ON than what they have so bloody well stood FOR up to now.” Kenneth Patchen, Poet
|
|
|
|
|
BillWoodruff wrote: all too typical of the so often valueless, poorly written, code samples on MSDN
You sir have not seen the "examples" and "documentation" put forth by Telerik and the Kendo UI library! That stuff makes Microsofts look absolutely awesome in comparison! No joke.
|
|
|
|
|
Dave Kreskowiak wrote: not seen the "examples" and "documentation" put forth by Telerik and the Kendo UI library Indeed, have not; I am grateful for such small blessings
“The best hope is that one of these days the Ground will get disgusted enough just to walk away ~ leaving people with nothing more to stand ON than what they have so bloody well stood FOR up to now.” Kenneth Patchen, Poet
|
|
|
|
|
Dave Kreskowiak wrote: "documentation" put forth by Telerik and the Kendo UI library! Don't know about Telerik but wholeheartedly agree about Kendo. One of the reasons we chose to not adopt that toolkit was the non-documentation.
/ravi
|
|
|
|
|
What did you get in its place?
|
|
|
|
|
We built our own framework on top of Dojo[^].
/ravi
|
|
|
|
|
It's a starting point which would, I hope, but know all too often will not, help the OP to a) make better use of search engines and MSDN, and b) think for themselves.
|
|
|
|
|
Thanks for you help! I'll find the solution. Sorry for reply later!
|
|
|
|
|
I am sure you learned a lot implementing a custom ComboBoxItem using 'OnDrawItem. As you've found out, trying to access the hidden internal ListView that is displayed when the ComboBox drops its DropDown is problematic.
The only Event I've found that lets you determine the location of the mouse for any action in a ComboBox DropDown, without using WinAPI, is the SelectedIndexChanged Event. Consider:
private private Point hitPoint;
private int deleteThreshold = 100;
private void SomeComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
hitPoint = SomeComboBox.PointToClient(MousePosition);
if(hitPoint.X > deleteThreshold) SomeComboBox.Items.Remove(SomeComboBox.SelectedItem);
} You could simplify this in a way that does not require 'OnDrawItem, however, the "sacrifice" would be that you would include the "X" as part of the Text of the ComboBoxItem itself, so the "X" could not appear in any special Font, not have any special formatting.
If you want to see an example of this, just let me know, and I'll post sample code here.
“The best hope is that one of these days the Ground will get disgusted enough just to walk away ~ leaving people with nothing more to stand ON than what they have so bloody well stood FOR up to now.” Kenneth Patchen, Poet
|
|
|
|
|
Thanks for your help Sir. I'll try your suggestion. I like DIY, not just taking.
|
|
|
|
|
Member 10413292 wrote: I like DIY, not just taking. That's a great attitude; my best wishes for your success Bill
“The best hope is that one of these days the Ground will get disgusted enough just to walk away ~ leaving people with nothing more to stand ON than what they have so bloody well stood FOR up to now.” Kenneth Patchen, Poet
|
|
|
|
|
hi ,i use 4 picture box in my project and i write some codes in mouse_enter and mouse_leave event of this picture box it's here:
Size s;
Point p;
private void pbReporting_MouseEnter(object sender, EventArgs e)
{
s = pbReporting.Size;
p = pbReporting.Location;
pbReporting.Size=new Size(s.Width+12,s.Height+12);
pbReporting.Location=new Point(p.X-6,p.Y-6);
Refresh();
}
private void pbReporting_MouseLeave(object sender, EventArgs e)
{
pbReporting.Size = s;
pbReporting.Location = p;
Refresh();
}
and when i execute my project it's ok but when i choose a background for my form when mouse go to on picture box and leave it,it's has a slow motion moving.
you can download my project HERE:
http://Trainbit.com/files/6220359884/WindowsFormsApplication2.zip[^]
can you help me???
|
|
|
|
|
I assume this is a Windows Form project. ... yes ?
First, check these to see if they make any difference:
1. make sure your Form's 'DoubleBuffered Property is set to 'true
2. try taking out the calls to 'Refresh in your 'MouseEnter and 'MouseLeave EventHandlers.
Then, you might try this:
private int pbSizeIncrement = 12;
private Size pbBaseSize;
private Size pbEnterSize;
private Point pbBaseLocation;
private Point pbEnterLocation;
private void Form1_Load(object sender, EventArgs e)
{
pbBaseSize = pictureBox1.Size;
pbEnterSize = new Size(pbBaseSize.Width + pbSizeIncrement, pbBaseSize.Height + pbSizeIncrement);
pbBaseLocation = pictureBox1.Location;
pbEnterLocation = pbBaseLocation;
pbEnterLocation.Offset(pbSizeIncrement / -2, pbSizeIncrement / -2);
}
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
pictureBox1.Size = pbEnterSize;
pictureBox1.Location = pbEnterLocation;
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
pictureBox1.Size = pbBaseSize;
pictureBox1.Location = pbBaseLocation;
} I might also experiment by having two PictureBoxes defined, holding the same Image, but one sized larger than the other, and then switching the visibility of the two. You could position the second, larger, PictureBox correctly, and set its initial 'Visible state to 'false. Then:
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
pictureBox2.Visible = true;
pictureBox1.Visible = false;
}
private void pictureBox2_MouseLeave(object sender, EventArgs e)
{
pictureBox1.Visible = true;
pictureBox2.Visible = false;
} That would have the advantage of requiring no load-time calculation, and no run-time resizing/re-positioning of a PictureBox.
If none of these suggestions makes any real difference in run-time behavior, I'd certainly want to consider the nature of your hardware (cpu speed, amount of ram, etc.), and I'd want to take a close look at the sources of your images to see what their size, and formats were.
“The best hope is that one of these days the Ground will get disgusted enough just to walk away ~ leaving people with nothing more to stand ON than what they have so bloody well stood FOR up to now.” Kenneth Patchen, Poet
|
|
|
|
|
|
HI All,
Could any one please help on below
I want to open and save a pdf file using AcroRd32.exe command line and have to supress the GUI.
If above one is not possible (since most of them told its not possible), Please post if any alternatives with C#/Batch file/Command Line.
Thanks in advance..
Kind Regards,
Naresh M
|
|
|
|