C# Calendar Object on top - c#

Hi programming some C# in a form with a bunch of group boxes. I have a two Calendar controls that when called upon, are partially invisible due to surrounding group boxes.
this.grp_TransactionDetails.Controls.Add(this.cal_Ctrl);
this.grp_TransactionDetails.Controls.Add(this.cal_Batch);
Any ideas? (I wish there was a z-index property)

Controls in .Net have a BringToFront() method that might be what you need. Calling this method on a control brings it to the front of the z-order (SendToBack() has the opposite effect, as you might expect).

To fix this, I had to actually change the order in which the controls were added to the form. I changed the order in the Initialze() method of the form.

Related

How to make message entry/list/view in C#

He I am a beginner to C# and I am working on a reaction manager plug-in for some bigger project. (Yes I am a intern)
Now I just can't find a way to create a view similar to this:
My full design:
How to realize this design? I cant find any default templates in the devexpress which are suitable for this. I come from php and in php I can use html. I am a beginner to C# and I don't have any clue on how t do this. Do I have to use canvas to literally draw this? OR is there a standard template I can use for this purpose.
You have many comment boxes that contain the same layout - a label comment text, author name, date, etc. There is no control that lays things out like that, you will have to make your own custom control (Project->Add User Control). This control will be a composite control - ie made up of other controls. Probably a label for each text field (comment, author, date, etc) laid out in the right places. Maybe call it CommentBox or something.
Then in the main form you now have available CommentBox controls which you can add to the form. Create a panel to put them in so you have many CommentBox controls in the panel, one for each comment (or maybe add them at runtime).
Now in WPF it's slightly easier because there is a StackPanel control that you can simply add controls to and it automatically arranges them vertically one beneath another in a stacked list. In fact your use case is exactly fitting what a StackPanel is for.
In WinForms there is no StackPanel, but you can use a normal Panel control*. It's just you'll have to position the CommentBox controls manually one beneath another. You will also need to set the AutoScroll property to true to turn on the vertical scroll bar if the content doesn't fit the view.
*or there's apparently an alternative How can I get a StackPanel-like layout in WinForms

Removing control from panel doesn't remove it from the Form?

I have a routine where I loop recursively through all the controls on a form and process some code on some of them.
I add and remove controls through the use of the screen depending on selections the user makes.
I found that panel.Controls.Remove(control1) didn't actually remove it from the form. When I would run the routine that loops recursively through the controls on the form, the control I thought I had remove was still being found.
It didn't "disappear" until I did:
panel.Controls.Remove(control1);
this.Controls.Remove(control1)
Is this expected? Can someone explain this to me, and or point me to somewhere that explains control behavior in Windows Forms.
Thanks!
Clearly the control has the form as its Parent, not the panel. These kind of accidents tend to happen easily with the designer. You can use View + Other Windows + Document Layout to get a good view of the child-parent relationships. You can use drag+drop in this list to fix.

What would be the best course of action for display different form in a single Winform?

Here's a screenshot of my application:
Basically, depending on what option is selected I'd like to show another 'content' which can be a buttons, or forms or whatever.
What would be the best choice for this? Using MDI? I'm really new to this type of thing.
This scenario lends itself well to tab pages, as you'd find on a TabControl.
However, since you already have a mechanism for switching between the content, you might prefer to create a series of Panels whose Dock property is set to DockStyle.Fill. When the user clicks the appropriate heading, you simply need to show the appropriate panel and call BringToFront() on it. This is essentially what the tab control does internally, anyway.
Don't forget to use SuspendLayout() and ResumeLayout() appropriately to reduce flicker, which can be a huge problem in WinForms applications, especially when there are lots of controls.
You can position a TabControl where the buttons are not visible and control it from your buttons.

adding a windows form object to listbox

I'm creating a twitter client in C#.
I want to put every tweet as an element of a listbox.
I created a windows form that represents a tweet(it has a picture, and labels).
My problem is that when i can't see the tweets when i add them to the listbox. After adding 3 tweets(windows form objects), the listbox has 3 blank elements in them, but i can't see anything of it.
How can i add a windows form object to a listbox?
(these forms are working fine, because i can see them if i use the ShowDialog method)
please help
You can add a Form object to the ListBox.Items collection but the only thing you'll ever see is the type name of the form. ListBox is not capable of rendering controls as its items.
The efficient solution is to implement the ListBox.DrawItem event and custom draw the tweet. There's a good example of such an event handler in the MSDN Library documentation for the event.
The slow solution is to add controls to a Panel's Collection property with its AutoScroll property set to true. That cannot be a form, it must be a UserControl.
You may want to look into implementing it using WPF. Where you can pretty much put anything inside a listbox.
Some thoughts:
You'd do better to work with custom controls, rather than a whole form
A listbox can't have controls on it... consider a ListView: http://www.codeproject.com/KB/list/ListViewEmbeddedControls.aspx
Some example code of what you're trying will help us zoom in on what you're doing
HTH,
James
I don't think ListBox can display anything but a text string for each element, so you won't be able to see an image of each form if that's what you were hoping for. You might try using FlowLayoutPanel instead to manage a list of controls.

WinForms TabOrder tool: Broken or just confusing?

I have a form with a bunch of panels, and some panels inside groupboxes. When using the TabOrder tool in Vs2005, the controls outside of containers are given integers (0), the controls inside panels are given decimals (72.0), and the controls within panels within groupboxes are given three-part values (73.73.0). Unfortunately the resulting tab order has nothing to do with the order I clicked my controls.
Does this tool simply not support nested containers? Am I doing something wrong? Perhaps holding Shift- or Ctrl- when I click (I've tried these with no success)?
Am I going to be forced to manually type in three-part tab orders for all my controls? That would be a bummer.
The tab order tool is not designed for you to enter values manually; it is designed for you to click on controls in the order that you'd like them to progress as the user tabs.
The numbers are not decimals; they represent the tab order of the control within its parent container. For example, if you have a Form with a Panel named panel1 and a Button inside of it named button1, then button1 would display a number like:
X.Y
X is the tab order of panel1
Y is the tab order of button1 within panel1.
I will acknowledge that the designer isn't as intuitive (or transparent) as it probably should be, but it does work.
I had the same problem with textboxes and buttons within group box in VS2010. TabOrder tool was just useless: Tab orders were broken no matter how I re-ordered the tab stops. In order to make the correct tab order I had to re-order of how controls are added to the group box in form designer initialization code:
this.groupBox2.Controls.Add(this.startTimeTextBox);
this.groupBox2.Controls.Add(this.endTimeTextBox);
this.groupBox2.Controls.Add(this.exitButton);
This way tab order would be startTimeTextBox -> endTimeTextBox -> exitButton and so on.
I think I figured out the way to do it in the designer: the trick is apparently that you have to click the panels/groupboxes as well in order to assign the different parts of the full ordering; in this way, it seems that a bredth-first clicking method needs to be used as opposed to clicking the child controls themselves.
Kinda sad, since it forces you to know the full structure of the whole form instead of just what the user sees.
I had this same problem and discovered this tool: http://archive.msdn.microsoft.com/cdstabindex
I had to change the manifest to make it work with VS2010 though. Also, I've modified the source code for myself to make the UI a little better, but even as it is, I would recommend having a look at this tool.
Remove Group-boxes from Controls and try again this works for me :)

Categories

Resources