Draders23, Thanks so much for the link:). I tried overriding the WndProc for the control and show my own customcontrol instead of regular dropdown. Thanks, VPMahank
VPMahank
Posts
-
Combobox question -
Combobox questionHai all, I want to show a UserControl instead of the default dropdown list when I click on the ComboBox dropdown arrow. Is there a way to catch this message and show my control instead of this? Thanks in advance. VPMahank
-
Border Color customization in ListBox and CheckedListBoxWith BorderStyle set to Fixed Single, in the Paint method I tried to draw my own border color but the Paint would never get called for ListBox/CheckedListBox. Is there any difference from ListBox/CheckedListBox and other controls. I know that we need to override OnDrawItem , OnMeasureItem to customize the items in the ListBox but how do I change the border color of the ListBox itself? protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (this.BorderStyle == BorderStyle.FixedSingle) System.Windows.Forms.ControlPaint.DrawBorder(e.Graphics, ClientRectangle, _borderColor, ButtonBorderStyle.Solid); } Thanks in advance, VPMahank
-
Groupbox border colorI am using .Net Framework 2.0 winforms groupbox control. I would want to know on how to change the border color of the groupbox . Any ideas on how this would be achieved would be appreciated. Thanks, VPMahank
-
Data Adapter ??I installed VS2005 very recently. Where is the DataAdapter( all types sql,ole) object which usually shows up under the Data tab in the ToolBox in VS2005. Any help or links would be greatly appreciated. Thanks VPMahank.
-
Making the panel invisible??Yes, I totally understand. But if there are a bunch of controls in the form, lets say there are a few labels on the form, the visibility property of the panel has to be set on click event of each label. I cannot just handle it in the Click event of the form. I need to have a generic way of doing this. :confused: Thanks, VPMahank
-
Making the panel invisible??I have a list of buttons in the panel( one below the other. Just like a dropdowm menu). It is invisible by default. I have a button on the form. When I click the button on the form, I show the panel just below the button. Now when I click anywhere on the form other than the panel and buttons inside the panel, the panel should become invisible. Any ideas on how to achive this would be very much appreciated. Thanks, VPMahank.
-
Theme selection for Windows FormI have two to different sets of themes for my windows form. Selecting each form should change the Images, color sets and other appearance related properties for the controls on the form. What could be the best way to approach this problem. I was thinking of saving these setting in different XML files and read from them on fly when theme is changed by the user. But any other ideas or suggestions would be very much appreciated. I was thinking something like this........ images1 Red Dark Gray Thanks, VPMahank
-
DataGrid change any row color ( C# )Hai, You can actually inherit from DataGridColumnStyle and override the paint method where you check the condition and set the backbrush color accordingly. Just make sure all of your column styles has this code so the each column in row has same color. Hope this helps Thanks, VPMahank Here is a sample public class DataGridTextBoxColumnCustom : DataGridTextBoxColumn { /// /// Invalidates the display of this column, causing it to be repainted. /// public void Repaint() { Invalidate(); } protected SolidBrush _BackBrush = new SolidBrush(Color.White); protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight) { Brush bkBr = backBrush; try { // you condition check logic if( your condition == true) { backBrush = new SolidBrush(some color); } else if () backBrush = new SolidBrush(some color); else backBrush = new SolidBrush(some color); } catch (Exception exc) { } // ignore finally { base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight); } }
-
Round edge panelI am creating a round edge panel by inheriting from the panel. What I do is create a graphics path with desired shape and in the Paint method I fill the graphics path and draw the graphics path border with desired color. This would look as if the panel has round edges. So far I have not set the region. Bounds of the panel is still the rectangle. But the problem come when I set the region of the panel to the Graphics path region. It would not draw the borders( especially left and bottom) properly, it would not draw the curves properly. Also if I set the background image , the image is not smooth along the borders even though I set smoothing mode to AntiAliasing . Any ideas on why it is behaving this way would be greately appreciated. Here is the code in Paint method protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Graphics gr = e.Graphics; gr.SmoothingMode = SmoothingMode.AntiAlias; if(_roundedCorners) { // clear background with the parent's backcolor before drawing the round edges if( Parent.GetType() == typeof(RoundEdgePanel)) gr.Clear( ((RoundEdgePanel)Parent).PanelBackColor); else gr.Clear(Parent.BackColor); gr.DrawPath(_borderPen, _roundedEdge); // now fill with actual color gr.FillPath( _graphicsPathBrush,_roundedEdge); // setting the region of the control //this.Region = new Region( _roundedEdge); // this is where the problem comes } else { // set the back color to the color of _graphicsPathBackColor gr.Clear( _graphcsPathBackColor); gr.DrawPath(_borderPen, _squaredEdge); //gr.FillRegion( _graphicsPathBrush, this.Region); } } Thanks, VpMahank.
-
Control disappearing in the designer!!!!Thanks so much for the link. It was really helpful. Could you let me know on how to write a macro to say close all the designer windows in IDE just before making a build. Any links would also be great. Thanks in advance VPMahank.
-
Control disappearing in the designer!!!!Unfortunately I am using 2003. Is there anyway at all to avoid this. Thanks VPMahank
-
Control disappearing in the designer!!!!I have several custom controls in my form( eg: round edge panels, controls inherited from label abd button). Sometimes all the controls in my form suddenly disappear in the designer. This is really scary. Since I would have a backup in my source safe that saves me but could anyone explain this better so that I can avoid the cause of this action. Thanks in advance. VPMahank
-
change foreColorYou can change the forecolor of a specific column by setting the ForeColor property of that ColumnStyle(DataGridColumnStyle). To change the forecolor of a specific cell you have to override the paint method in DataGridColumnStyle in which you will check for a condition or the rowNum and then set the forecolor accordingly. Thanks, VPMahank
-
how to override the button draw event?Add a handler for MouseDown, MouseUp, MouseOver events for the Button and set the Image property accordingly.
-
Splitter between two panelsMy additional need was to have a splitter between controls that are not docked at all. So I need a control that behaves like a splitter but for undocked controls. Thanks, VPMahank
-
Splitter between two panelsOk what I was doing was a little different. I was resizing the panel each time the splitter is moved. So the two panels were resizing each time the MouseMove of the splitter is called. The problem with this the panel resizing is not done smoothly as required. I tried making a few changes to the code now. Relocating the splitter location in mouse move and relocating and resizing the panels in the mouseup. Here is what I did. Please let me know if I can improve this anymore and allow a cleaner dispaly. public class NoDockSplitter : Label { public NoDockSplitter() { // set styles to prevent flickering SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyles(); } protected void SetStyles() { this.BorderStyle = BorderStyle.None; this.Text = "|"; this.TextAlign = ContentAlignment.MiddleCenter; } protected Control _leftSideControl; protected Control _rightSideControl; public Control LeftSideControl { get { return _leftSideControl; } set { _leftSideControl =value; SetControlSize(_leftSideControl); } } public Control RightSideControl { get { return _rightSideControl; } set { _rightSideControl =value; SetControlSize( _rightSideControl); } } protected bool _mouseDown = false; protected bool _sizeSet = false; protected int _leftSideControlWidth = 0; protected int _rightSideControlWidth = 0; protected int _rightSideControlXPos = 0; protected int _splitterStartXPos = 0; protected bool _widthSet = false; protected int _diff = 0; protected int _startXPos = 0; protected void SetControlSize(Control c) { if(! _sizeSet ) { this.Size = new Size( 4, c.Height); _sizeSet = true; } } protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter (e); this.Cursor = Cursors.VSplit; if( !_widthSet) { _leftSideControlWidth = _leftSideControl.Width; _rightSideControlWidth = _rightSideControl.Width; _rightSideControlXPos = _rightSideControl.Location.X; _splitterStartXPos = this.Location.X; _widthSet = true; } } protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave (e); this.Cursor = Cursors.Default; } protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown (e); _mouseDown = true; _diff = 0
-
Splitter between two panelsI tried your suggestion. The idea works!!!. But the painting is not done neatly. I mean I have a inherited panel and I did set the styles to enable doubleBuffering. But using those panels would not paint properly when using the spiltter( I inherited splitter control from label and set the styles for this too). Please let me know if I am missing anything. Thanks, VPMahank.
-
Splitter between two panelsThanks for the idea Darryl. I will try it out. Thanks, VPMahank:)
-
currentcell backcolorIt seems you are selecting a cell in the programmatically in the mousemove event by setting the CurrentCell. That is the reason its hightligting the cell with the default color and text is highlighted. Since there is not mouseDown happening here , mouseeUp would not be called. Why do you need to set the CurrentCell in the mousemove anyway? Thanks, VPMahank