|
Hi Hzi,
First, thank you for commenting and find/resolve a bug with GotFocus and LostFocus. Today I updated the file of the sources with your corrections.
Greetings,
Marcelo Palladino
Brazil
|
|
|
|
|
Hi Marcelo,
When adding an Object to the listbox (Text and a Value), I can't get the text to display. I think this is a bug as the MS control worked fine with my code.
Keep up the good work.
Regards,
Jeff
|
|
|
|
|
Hi Jeff,
How do you do? Well, I believe that you are right! You can post your code (just a relevant snippet) for me to do a test similar to yours? Thank you again!
Hugs,
Marcelo Palladino
Brazil
|
|
|
|
|
Hi Marcelo,
Here is all the code from a Test VB form - if you replace all the code in a VB form with this then you can easily test.
The code has your Listbox and also the MS Listbox, your listbox does not show the text, whereas the MS does.
Regards,
Jeff
Public Class tester
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents ListBox1 As PallaControls.Windows.Forms.ListBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents ListBox2 As System.Windows.Forms.ListBox
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.ListBox1 = New PallaControls.Windows.Forms.ListBox
Me.Button1 = New System.Windows.Forms.Button
Me.ListBox2 = New System.Windows.Forms.ListBox
Me.SuspendLayout()
'
'ListBox1
'
Me.ListBox1.BorderColor = System.Drawing.Color.FromArgb(CType(222, Byte), CType(217, Byte), CType(207, Byte))
Me.ListBox1.BorderHotColor = System.Drawing.Color.FromArgb(CType(222, Byte), CType(217, Byte), CType(207, Byte))
Me.ListBox1.ColumnWidth = 0
Me.ListBox1.DockPadding.All = 1
Me.ListBox1.EditColor = System.Drawing.Color.FromArgb(CType(242, Byte), CType(242, Byte), CType(228, Byte))
Me.ListBox1.EditDisabledColor = System.Drawing.Color.FromArgb(CType(238, Byte), CType(238, Byte), CType(225, Byte))
Me.ListBox1.EditFocusedColor = System.Drawing.Color.White
Me.ListBox1.EditReadOnlyColor = System.Drawing.Color.FromArgb(CType(238, Byte), CType(238, Byte), CType(225, Byte))
Me.ListBox1.FlashColor = System.Drawing.Color.FromArgb(CType(170, Byte), CType(170, Byte), CType(221, Byte))
Me.ListBox1.Location = New System.Drawing.Point(28, 23)
Me.ListBox1.MultiColumn = False
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.ParentStyle = False
Me.ListBox1.SelectedIndex = -1
Me.ListBox1.SelectedItem = Nothing
Me.ListBox1.SelectedValue = Nothing
Me.ListBox1.SelectionMode = System.Windows.Forms.SelectionMode.One
Me.ListBox1.Size = New System.Drawing.Size(180, 173)
Me.ListBox1.Sorted = False
Me.ListBox1.Style = Nothing
Me.ListBox1.TabIndex = 0
Me.ListBox1.TextColor = System.Drawing.Color.Black
Me.ListBox1.TopIndex = 0
Me.ListBox1.ValueMember = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(147, 216)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(71, 28)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Test"
'
'ListBox2
'
Me.ListBox2.Location = New System.Drawing.Point(225, 17)
Me.ListBox2.Name = "ListBox2"
Me.ListBox2.Size = New System.Drawing.Size(182, 173)
Me.ListBox2.TabIndex = 2
'
'tester
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(418, 266)
Me.Controls.Add(Me.ListBox2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.ListBox1)
Me.Name = "tester"
Me.Text = "tester"
Me.ResumeLayout(False)
End Sub
#End Region
Public Class GroupClass
Friend Structure struct_StockGroup
Friend ID As Long
Friend Description As String
Public Overrides Function ToString() As String
Return Description
End Function
End Structure
Friend Record() As struct_StockGroup
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim g As New GroupClass
Dim i As Integer
For i = 1 To 10
ReDim Preserve g.Record(i)
g.Record(i).ID = i
g.Record(i).Description = "My Test " & CStr(i)
ListBox1.Items.Add(g.Record(i))
ListBox2.Items.Add(g.Record(i))
Next
End Sub
End Class
|
|
|
|
|
Hi Jeff,
Thank you for posting the code for test. Seemingly I got solved the bug that you told. Please see what happens in your cases.
Greetings,
Marcelo Palladino
Marcelo Palladino
Brazil
|
|
|
|
|
Marcelo,
Excellent package. Well done.
Regarding this ListBox issue...has it been resolved? I've got the same problem with the ComboBox, but only when databinding. Works fine if you add string items.
Thanks
Ron
|
|
|
|
|
Hi Ron,
Thank you for commenting. Only looks, seemingly I repaired this. If you have a code that is not working, send me so that I can try to reproduce the problem for here.
Hugs,
Marcelo Palladino
Brazil
|
|
|
|
|
Hi Marcelo,
The ComboBox control has to be a lot longer than the text within otherwise it won't show all the text.
Regards,
Jeff
|
|
|
|
|
Hello again, Jeff
The one that I did here went to increase the area of edition of the control. There is not a lot what to do, I hope this works.
Hugs,
Marcelo Palladino
Brazil
|
|
|
|
|
Hi, very nice controls, but.. how do i do if à just want one control ?
|
|
|
|
|
Hi krazitchek,
Thank you for your comment! See, you can detach any one of them calm. Perhaps the work that you have is due to hierarchy of the controls and the "married" functionalities as it is the case of StyleGuide control.
Hugs,
Marcelo Palladino
Brazil
|
|
|
|
|
Hi Marcelo,
The Enter Key does not register in Keypress/keydown/keyup in the ButtonEdit control.
In the TextBox control the Enter key only registers in the Keyup event
Regards,
Jeff
|
|
|
|
|
Hi Jeff,
You are right. I gave a "general cleaned " in the edition components for these subjects of the keys. I think now it is in the right road, still with some bugs but in the right road. See what you think...
Hugs,
Marcelo Palladino
Brazil
|
|
|
|
|
Hi,
The TextBox and ButtonEdit controls KeyPress/KeyUp/KeyDown events do not work.
Regards,
Jeff
|
|
|
|
|
Once again you are right, Jeff. In TextBox, ListBox, MenuListBox everything working well now. However, with ButtonEdit and ComboBox the event "KeyUp" is not still working. I will look with more calm in next days...
Thank you very much, once again and a great hug,
Marcelo Palladino
Brazil
|
|
|
|
|
Hi!
First of all: excellent work! These controls rock!!!!!
I ran into some slight problems with date parsing though. I'm Dutch, and we use dashes for dates, for one. Your controls had problem parsing them, accepting only slashes. Therefore I made some modifications that may help people using other cultural settings. The functions I have replaced are here:
(TextBoxBase.cs)
<br />
<small><br />
<pre><br />
protected virtual bool HandleTime(char keyChar)<br />
{<br />
if (!this.ReadOnly) <br />
{<br />
if (Char.IsDigit(keyChar) || <br />
keyChar == CultureInfo.CurrentCulture.DateTimeFormat.TimeSeparator[0] || keyChar == 8 ||<br />
keyChar == 22 || keyChar == 3 || <br />
keyChar == 26 || keyChar == 24)<br />
{ <br />
if (this.ErrorOcurred != null)<br />
{<br />
ErrorOcurredEventArgs oArg = new ErrorOcurredEventArgs("");<br />
ErrorOcurred(this, oArg); <br />
}<br />
<br />
if (keyChar != 8 && keyChar != 22 && <br />
keyChar != 3 && keyChar != 26 && keyChar != 24)<br />
{<br />
if (this.SelectedText == this.Text) this.Clear();<br />
if (keyChar != CultureInfo.CurrentCulture.DateTimeFormat.TimeSeparator[0] )<br />
{<br />
if (this.Text.Length == 2 || this.Text.Length == 5) <br />
this.AppendText(CultureInfo.CurrentCulture.DateTimeFormat.TimeSeparator);<br />
}<br />
if(this.Text.Length == 8)<br />
return true;<br />
}<br />
}<br />
else<br />
{<br />
ErrorOcurredEventArgs oArg = null;<br />
if (this.ErrorOcurred != null)<br />
{<br />
oArg = new ErrorOcurredEventArgs(ResourceLibrary.GetString(WindowsControlsResourceKeys.OnlyDigitsTwoPointsAccepted,WindowsControlsResourceKeys.Root));<br />
ErrorOcurred(this, oArg); <br />
}<br />
return true;<br />
}<br />
}<br />
return false;<br />
}<br />
<br />
<br />
protected virtual bool HandleDate(char keyChar)<br />
{<br />
if (!this.ReadOnly) <br />
{<br />
if (Char.IsDigit(keyChar) || <br />
keyChar == CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator[0] || keyChar == 8 ||<br />
keyChar == 22 || keyChar == 3 || <br />
keyChar == 26 || keyChar == 24 || keyChar == 27)<br />
{ <br />
if (this.ErrorOcurred != null)<br />
{<br />
ErrorOcurredEventArgs oArg = new ErrorOcurredEventArgs("");<br />
ErrorOcurred(this, oArg); <br />
}<br />
<br />
if (keyChar != 8 && keyChar != 22 && <br />
keyChar != 3 && keyChar != 26 && keyChar != 24 && keyChar != 27)<br />
{<br />
if (this.SelectedText == this.Text) this.Clear();<br />
if (keyChar != CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator[0] )<br />
{<br />
if (this.Text.Length == 2 || this.Text.Length == 5) <br />
this.AppendText(CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator);<br />
}<br />
if(this.Text.Length == 10)<br />
return true;<br />
}<br />
}<br />
else<br />
{<br />
ErrorOcurredEventArgs oArg = null;<br />
if (this.ErrorOcurred != null)<br />
{<br />
oArg = new ErrorOcurredEventArgs(ResourceLibrary.GetString(WindowsControlsResourceKeys.OnlyDigitsBarAccepted,WindowsControlsResourceKeys.Root));<br />
ErrorOcurred(this, oArg); <br />
}<br />
return true;<br />
}<br />
}<br />
return false;<br />
}<br />
<br />
private bool ValidateDate()<br />
{<br />
if (this.Required || this.TextLength > 0)<br />
{<br />
<br />
DateTimeFormatInfo format = CultureInfo.CurrentCulture.DateTimeFormat;<br />
try<br />
{<br />
<br />
DateTime.Parse(this.Text, format);<br />
<br />
}<br />
catch<br />
{<br />
<br />
if (this.ErrorOcurred != null)<br />
{<br />
string sDateFormat = format.ShortDatePattern;<br />
<br />
ErrorOcurredEventArgs oArg = new ErrorOcurredEventArgs(string.Format(ResourceLibrary.GetString(WindowsControlsResourceKeys.InvalidDateFormat,WindowsControlsResourceKeys.Root), sDateFormat));<br />
ErrorOcurred(this, oArg); <br />
}<br />
return true;<br />
<br />
}<br />
}<br />
return false;<br />
}<br />
<br />
<br />
protected virtual bool ValidateTime()<br />
{<br />
if (this.Required || this.TextLength > 0)<br />
{<br />
DateTimeFormatInfo format = CultureInfo.CurrentCulture.DateTimeFormat;<br />
<br />
try<br />
{<br />
<br />
DateTime.Parse(this.Text, format);<br />
if (!CommonHelpers.IsDateOk(this.Text))<br />
{<br />
if (this.ErrorOcurred != null)<br />
{<br />
ErrorOcurredEventArgs oArg = new ErrorOcurredEventArgs(string.Format(ResourceLibrary.GetString(WindowsControlsResourceKeys.InvalidTime,WindowsControlsResourceKeys.Root), format.ShortTimePattern));<br />
ErrorOcurred(this, oArg); <br />
}<br />
return true;<br />
}<br />
<br />
}<br />
catch<br />
{<br />
<br />
if (this.ErrorOcurred != null)<br />
{<br />
ErrorOcurredEventArgs oArg = new ErrorOcurredEventArgs(ResourceLibrary.GetString(WindowsControlsResourceKeys.InvalidTimeFormat,WindowsControlsResourceKeys.Root));<br />
ErrorOcurred(this, oArg); <br />
}<br />
return true;<br />
}<br />
}<br />
return false;<br />
}<br />
<br />
</pre><br />
</small><br />
These replacements seem to solve international handling. Please note a change I made in my resources. Instead of having a text like 'Invalid date format; 00/00/0000' in the resource file, I replaced it with 'Invalid date format; {0}'. The {0} is replaced in the error messages with the correct cultural pattern for either date or time.
I hope these changes help. In the meantime, I'll look into more extentions. For instance, I'd like to add a regular expression as a mask. Also I'm looking for a way to infuse my own message at run time in the error provider.
Keep up the excellent work!
Best regards,
Geri
|
|
|
|
|
WOW! Thank you for your alterations (they helped too much). You are really right, was very better!! As your ideas, I was thinking about creating one more mask (CustomWithRegularExpression) and a property for RegularExpression. For message, to create an event that would only be generated when it happens a mistake with this mask (validate). This event could have an argument (e.CustomErrorMessage) that would be reviewed internally for ErrorProvider. What do you think?
Once again thank you very much and I wait that we speak to each other more times.
Hugs,
Marcelo Palladino
Brazil
|
|
|
|
|
Hi Marcelo!
The regular expression solution sounds great.
The custom error message should always override the internal messages. They should, ofcourse, only be displayed in the ErrorProvider when validation fails. So if the validation fails, the custom error message should be displayed when there is one, otherwise the internal message should be shown.
Another small thing I ran into. Try the following: Set a textbox to Numeric. DecMinVal = 2, DecMaxVal = 100. Now try press 1... At least, it failed with me. But maybe I messed around in a wrong place, who knows... Blocking the following piece of code from HandleNumeric solved it for me though:
string nText = val.Insert(curPos,pressedChar.ToString(CultureInfo.CurrentCulture));
double decVal = CommonHelpers.StringToDouble(nText);
if(decVal > mDecMaxValue || decVal < mDecMinValue)
{
return false;
}
I hope it helps!
Hugs,
Geri
|
|
|
|
|
Hi Geri,
You this certain!! There is a bug there... That I did was the following: Removed the verification of the method "HandleNumeric" (the code that you highlighted) and added a validation in method "ValidateNumber". In case the number is "out of the established strip", ErrorProvider shows the following message: Number out of the allowed strip; '{0}' - '{1}'. Seems that it works well, see what you think. Thank you again!
Hugs,
Marcelo Palladino
Brazil
|
|
|
|
|
Hi Marcello,
I've added some functionality to the StyleGuide, for my own purposes: it can save and load to file now. I may add some encryption functionality later. I've done this, so it is easy to distribute new color schemes this way. The saved file contains the version of the assembly, so incompatibility of files shouldn't matter much, since you can keep the code form your previous schemes, or create convertor functions to support older file types.
If you would like the changes, please drop me an email (either to geri.wolters@aquasense.nl, or to geri@wolters.nu, or post your email address here), so I can send you the updated version of StyleGuide. The changes are a bit too large to post here, I'm afraid.
Have a great weekend!
Geri
|
|
|
|
|
Hi,
Your controls are very very good - so much so that I have stopped using some very expensive well known controls in favour of yours as they are simple,lightweight and look cool. I do hope you continue to improve and expand these controls.
Can you pretty please fix the BorderHotColor as this does not work - I did have a look myself but I'm a VB user, so got a little lost.
Many thanks,
Jeff
|
|
|
|
|
Whoops!
Sorry I mean the Button Border Hot Colour.
Jeff
|
|
|
|
|
Hi JeffGreen,
Thank you for your comment. There was a bug in the routines that draw the borders, they were changing the colors. It seems that was now good. Thank you once again!!
Hugs,
Marcelo Palladino
Brazil
|
|
|
|
|
Hi Marcelo,
Did you fix the ButtonHotBorder?, as I re-downloaded and this still does not work.
Thankyou for your hard work and patience.
Regards,
Jeff
|
|
|
|
|
Whoops!
I ended up making the test without StyleGuide. Now I think was right! You that thinks now...
Hugs,
Marcelo Palladino
Brazil
|
|
|
|
|