|
Hi
I have 1 User Control (With 10 Labels)
when i click on each label i want to open different forms with same Mdi Parent..
i am using Usercontrol in eg(Root form)
when i click on Root form's Usercontrol (label1,2,3......and 10)
i want Mdi Parent as (Root - Mdi parent) for all lable clicks
Even though we are able to open different forms, but it is not opening as single form within a single MDI.
Thanks in advance..
-- Modified Friday, February 26, 2010 2:28 AM
|
|
|
|
|
|
I have a DataTable that has three columns, named “Department”, “Manager”, “Employee”
The data looks like:
Accounting – John M – Mark E
Accounting – John M – Jane E
Accounting – Tim M – Bob E
Sales – Tom M – Matt E
Sales – Phil M – Jill E
And I have three combo boxes that represent each column in the DataTable:
departmentComboBox
managerComboBox
employeeComboBox
and finally I have a BindingSource that is being bound to each combo box, with each combo box’s .DisplayMember set to the proper column name
My issue: Each combo box displays 5 items... meaning the departmentComboBox shows “Accounting” three times and “Sales” twice, and similar for the other two ComboBoxes.
How can I have each ComboBox display only the unique and appropriate items based on the BindingSource’s current position? So if the first row is my current position in the DataTable, the combo boxes should have:
departmentComboBox = {“Accounting”, “Sales” } (with “Accounting” selected)
managerComboBox = {“John M”, “Tim M”} (with “John M”) selected)
employeeComboBox = {“Mark E”, “Jane E”} (with “Mark E” selected)
The only way I’ve seen that I might be able to do this is by having three DataTables and create a relationship between each of them, but I was hoping there was a more direct way...
Thank you all for your time,
Matt
|
|
|
|
|
write your unique data display logic in event handler of DataBinding event. Thanks,
Arindam D Tewary
|
|
|
|
|
Are there any methods available in Diagnostics or other class that will output the function name when it is entered/left? I need to trace execution through some spaghetti code I've inherited, and I'm hoping to avoid hand-coding enter/leave WriteLines.
|
|
|
|
|
You could use the debug method.
For more information, see here[^].Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Hi,
Something like this should do the trick;
System.Diagnostics.Debug.WriteLine(
new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name);
or, if you wanted to put this in a utility funtion;
public static string GetCurrentMethodName()
{
return new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().Name;
}
You've already looked at log4net? I found it to be a real help, combined with OneNote I are Troll
|
|
|
|
|
You might find Spring.NET's AOP support useful. I've used the Java equivalent, but not the .NET version. It allows you to instrument existing code to add functionality such as you describe, without having to change the existing source.
I don't really like AOP but it can be useful for situations like this.
|
|
|
|
|
Hi,
I previously created clickable thumbnails by assigning them to a picturebox instance and
then adding them to the flowlayoutpanel.
So i now i decided to experiment with listview control and ImageList control. I would like to display the thumbnail and the image title. Then once you click on the thumbnail the image appears at its original resolution.
But i'm having some issues and I would appreciate if you could help me please regarding this?
Firstly, I am trying to use an exisiting class that I created which would take in the filepath of the selected image which would then allow me to view the image at its original resolution.
Intially the problem i had regarding the listview was when i click on an image, the selected image didnt come up, another image came up.
For example i loaded 2 images. One called GoldFish.jpg and the other Rabbit.jpg. But when i click on Goldfish, rabbit appears instead.
When i click on Rabbit, Rabbit appears as expected. I think it is something to do with the index possibly?
I have now modified the code so that the in the ImageList i add the key and the actual image. So i decided to store the filepath and the thumbnail.
Regarding the ListView i decided to store the filename along with the filePath e.g "rabbit.jpg", "c:\\sample\\rabbit.jpg"
I then used the mouse click event to access the filePath and pass it into another form.
The following snippet is also causing an issue too:
/if i take this code out, the thumbnails are not displayed but if i click on
for (int j = 0; j < pathes.Length; j++)
{
this.listView1.Items[j].ImageIndex = j;
}
But if i use the above code then the thumbnails appear but when i click on the image i get the following error message on the click event of the list view.
"Path is not of legal form".
I just want to display the thumbnail images with the filename and when you click on the image you can view the image at
its original resolution.
Here is my full code.
private void Form1_Load(object sender, EventArgs e)
{
imageList1.ImageSize = new Size(108, 108);
imageList1.ColorDepth = ColorDepth.Depth24Bit;
string[] pathes = new string [] { @"c:\\sample\\Goldfish.jpg", @"c:\\sample\\Rabbit.jpg" };
foreach (string path in pathes)
{
string[] currentPath = path.Split(new char[] { '\\' });
string fileName = currentPath[currentPath.Length - 1];
Image thumbnail = ThumbnailCreator(path);
imageList1.Images.Add(path,thumbnail);
listView1.Items.Add(fileName,path);
}
for (int j = 0; j < pathes.Length; j++)
{
this.listView1.Items[j].ImageIndex = j;
}
this.listView1.View = View.LargeIcon;
this.listView1.LargeImageList = imageList1;
}
private void Image_click(object sender, EventArgs e)
{
listView1 = (ListView)sender;
String thePath = ((string)((Control)sender).Tag);
ImageViewer imageViewer = new ImageViewer(thePath);
imageViewer.Show();
}
private void listView1_MouseClick(object sender, MouseEventArgs e)
{
try
{
ListView.SelectedListViewItemCollection slvc = listView1.SelectedItems;
string apath = slvc[0].ImageKey;
ImageViewer iv = new ImageViewer(apath);
iv.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
I would also like to draw the thumbnails whilst maintaining the aspect ratio.Any advice on this please?
Thanks in advance.
|
|
|
|
|
you used line:
string[] pathes = new string [] { @"c:\\sample\\Goldfish.jpg", @"c:\\sample\\Rabbit.jpg" };
Lose either @ or replace '\\' to '\'. If you use @, then string will ignore escape characters.
|
|
|
|
|
Hi, thanks for the advice. I amended the file path as you advised by using just '\' and it appears to be working. I had to set to the listview properties such as View and LargeIcon before the creation of the images.
|
|
|
|
|
Hello,
I build a service in c# .Net and I also build setup for my service.
I install the service and i add that service to my service windows.
When i try to start the service i get a message that the process don't have job to do.
What can be the problem? Somebody knows maybe?this is known error?
Thank you.
|
|
|
|
|
noamtzu00 wrote: What can be the problem? Somebody knows maybe?this is known error?
Don't Know., Nope and nope
That is bad question. Does it throw exception? also did you consider remote debug?
|
|
|
|
|
i get a message that the process don't have job to do.
|
|
|
|
|
Doesn't mean anything to me
|
|
|
|
|
Try debugging the service to see what error is occuring. You can do this by adding the line below to your Main method before calling ServiceBase.Run :
System.Diagnostics.Debugger.Launch();
|
|
|
|
|
I can debugging in Visual-Studio?are ou sure?
|
|
|
|
|
noamtzu00 wrote: are ou sure
Well try it and find out.Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Works for me.
Usually I would attach to the running process, but in this instance you are dealing with the OnStart method so the only way is to make the code launch the debuger.
|
|
|
|
|
Hi All
I have a small doubt regarding a Forms.Timer and WM_TIMER.
If I remember right each System.Windows.Timer.Forms triggers an event ( bounded to the Tick event )
for each WM_TIMER message coming from the message pump of the Form where is included.
Since each of this WM_TIMER messages comes from the main message queue of Window OS,
if I Have 30 forms on my screen, each with its own Forms.Timer object updating
some graphic component of the form (label text, or other ), can I say that
each form will be strictly updated one after one?
I don't know how WM_TIMER is dispatched and processed in each form given that
the queue of the OS is unique and shared by all the forms.
Regards
Manustone
|
|
|
|
|
manustone wrote: can I say that
each form will be strictly updated one after one?
No, you can't predict order of update. I woud recommend a custom event placed on a global, so that all forms inside process coud accsess and one timer. Every form can subscribe to that event, and Timer.Tick event can fire other events in other of subscription.
|
|
|
|
|
Thanks for your response!
|
|
|
|
|
30 forms on your screen? I do hope you have a large monitor.
Each form, being a window has its own message loop. WM_TIMER messages are posted (ie. asynchronous) to the loop and are fired pretty much 'on idle'. Should one of you forms be busy, the timer event won't get through so you really can't guarantee order, or for that matter regular updates.Regards,
Rob Philpott.
|
|
|
|
|
Hi Rob! Thanks for your reply!
So at the end regular updates cannot be guaranteed using WM_TIMER.
What if I use 30 System.Threading.Timers for that purpose?
Do C# create a thread for each System.Threading.Timers or not?
If it does than probably it is better a ThreadPool..
what are your thoughts?
|
|
|
|
|
If all the timers must have the same interval, the best option is to use only one timer for all.
|
|
|
|