I have created a custom control like below. public partial class TextBoxEx : TextBox { public TextBoxEx() { InitializeComponent(); Font = Utility.normalFont; } protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); } } //A utility class to initialize font. class Utility { internal static Font normalFont = new Font("Arial", 18); } I have two forms Form1 and Form2. This TextBoxEx is added to Form2. I am showing Form2 when clicking a button in Form1. Continuously showing and closing Form2 causes GDI leak in my application. After analysing with a GDI detection tool(Bear.exe), it is found that the Font causes GDI leak. …

Member Avatar
Member Avatar
+0 forum 4

According to MSDN: Control.Disposing Property Gets a value indicating whether the base Control class is in the process of disposing. But when I checked, Disposing property of the control is always false (inside the Dispose() method itself). When will this Disposing property become true?

Member Avatar
Member Avatar
+0 forum 2

What is the difference between try { //Some code } catch { } and try { //Some code } catch(Exception) { }

Member Avatar
Member Avatar
+0 forum 6

Hi All, I have a TextBox in my Form and I am drawing a string into it as below. Font myFont = new Font("Arial",18F,FontStyle.Regular,GraphicsUnit.Point,128); Graphics g = myTextBox.CreateGraphics(); Brush b = new SolidBrush(Color.Red); g.DrawString("Item Drawn with DrawString",myFont ,b,new PointF(1,1)); The string displayed in the TextBox. Then I tried below code Font myFont = new Font("Arial",18F,FontStyle.Regular,GraphicsUnit.Point,128); Graphics g = myTextBox.CreateGraphics(); TextRenderer.DrawText(g,"Item Drawn with DrawText",myFont,new Point(1,1),Color.Red); Here the problem comes. Even though two methods g.DrawString() and TextRenderer.DrawText() uses same font, there is a difference in font style. That is some characters are rendered differently. If I use "1" instead of "128" in …

Member Avatar
Member Avatar
+0 forum 1

I have created a custom combo box(Text box, button and List View). While typing in the text box, cursor disappears. How can I disable "Hiding cursor while typing" in my application. I goggled and found that it is the system behavior called SPI_SETMOUSEVANISH. It can be turned off but it will affect applications. How can I turn-off this only in my custom control?

Member Avatar
Member Avatar
+0 forum 2

Hi All, Can I show input cursor in a non-focused RichTextBox? In my project, I have a RichTextBox and a ListView control. The focus should be on ListView control. I could handle the KeyPress and KeyDown events of ListView and re-directed to RichTextBox to enable typing. But how can I show cursor on RichTextBox. RichTextBox.focus() cann't be called. The focus must be in ListViewControl (like combobox ). Any Idea....?

Member Avatar
Member Avatar
+0 forum 3

Hi, I am trying to customize default windows scrollbar in combobox like below. public partial class ComboEx : ComboBox { internal ScrollbarEx vScrollBar; NativeListWindow listControl; public ComboEx() { InitializeComponent(); DropDownHeight = 100; vScrollBar = new ScrollbarEx(); } protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); } protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); COMBOBOXINFO combInfo = new COMBOBOXINFO(); combInfo.cbSize = Marshal.SizeOf(combInfo); Win32.GetComboBoxInfo( this.Handle, ref combInfo ); listControl = new NativeListWindow(this, combInfo.hwndList); } protected override void WndProc(ref Message m) { if (m.Msg == (Win32.WM_REFLECT + Win32.WM_COMMAND)) { if (Win32.HIWORD( (int)m.WParam ) == Win32.CBN_DROPDOWN) { COMBOBOXINFO combInfo = new COMBOBOXINFO(); combInfo.cbSize = Marshal.SizeOf(combInfo); …

Member Avatar
Member Avatar
+0 forum 2

Hi, I have a custom combobox (say ComboExt). I need to host this control in datagridview. In MSDN (http://msdn.microsoft.com/en-us/library/7tas5c80.aspx), they are saying, to host custom controls, my own column types with cells should be created. That is, I need to create a custom ComboExtColumn derived from DataGridViewColumn and all properties in DataGridViewComboBoxColumn like DataSource,Items, AutoComplete etc should be implemetend. I feel it is very complicated. My question is, Could I use DataGridViewComboBoxColumn instead of DataGridViewColumn to host my custom combobox(ComboExt) in DataGridView like as below? public class ComboExtColumn : DataGridViewComboBoxColumn { //Code } public class ComboExtCell : DataGridViewComboBoxCell { //Code …

Member Avatar
Member Avatar
+0 forum 2

I have a custom ObjectCollection class in my custom control and a public property to access this collection. //My custom Property [Editor("System.Windows.Forms.Design.StringCollectionEditor",typeof(UITypeEditor))] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ObjectCollection Items { get { return itemCollection; } } //My custom collection class [ListBindable(false)] public class ObjectCollection : IList, ICollection, IEnumerable { //code } However, the values are NOT getting persisted. In design mode if I save strings in StringEditor by clicking OK button, close it, and reopen it, then the strings are gone. Any idea?

Member Avatar
Member Avatar
+0 forum 1

The End.