|
|
Please i have created a form with several textboxes i want the error indicator code to prompt a user to type a value in case the user did not put any value in the text box click on the save button
modified 10-Feb-16 5:13am.
|
|
|
|
|
You probably need to subscribe to one of the events that fires when text changes: TextBox Events (System.Windows.Forms)[^]. You should also disable the Save button until all text fields have been successfully validated.
|
|
|
|
|
Well, you're not going to get any code. This is a education problem. You have to learn how validation works and write your own code.
Google for vb.net Windows Forms validation tutorial[^] and start reading.
|
|
|
|
|
Hi i want that merge columns of string values join in single cell in vb report by using group
Data
ID Name
1 paint
1 cross
1 less
2 to
2 gain
3 increase
I need in report as
ID Name
1 paint, cross, less
2 to, gain
3 increase
|
|
|
|
|
Was a bit trickier than I first thought - but here it is :
Dim arr() As String = New String() {"ID Name", "1 paint", "1 cross", "1 less", "2 to", "2 gain", "3 increase"}
Dim newstring As String = "", endstr As String = ""
Dim c As Integer = 1, num As Integer
Dim newnum As Boolean = True
For i = 0 To arr.Count - 1
If i > 0 Then
If Integer.TryParse(arr(i).Substring(0, i.ToString.Length), num) And num = c Then
If newnum = True Then newstring += num.ToString & " "
newstring += arr(i).Substring(i.ToString.Length + 1, arr(i).ToString.Length - i.ToString.Length - 1)
End If
If (i + 1) <= (arr.Count - 1) Then
If Integer.TryParse(arr(i + 1).Substring(0, (i + 1).ToString.Length), num) And num = c Then
newstring += ", "
newnum = False
Else
endstr = newstring
newstring = ""
newnum = True
End If
Else
endstr = newstring
newnum = True
End If
c = num
Else
endstr = arr(i).ToString
newnum = True
End If
If newnum = True Then Debug.Print("##### : " & endstr)
Next i
|
|
|
|
|
Hello !
I'm developing an application on vb.net 2013.
On my pc I'm using my screen resolution as a standard for Form's size , and object's size inside forms.
Of course , on my pc all the forms looks as should be.
But if try to run the application on a greater resolution , the forms and objects are small and the text almost unreadable . If I try to run on a smaller resolution , the forms became larger and objects and text very ugly.
Is there any technique or tool , in order to design form's independent from screen resolution ?
Thank you !
|
|
|
|
|
satc wrote: Is there any technique or tool , in order to design form's independent from
screen resolution ? Heaven forbid, no. It would mean that someone starts designing on his 640x480 and then projecting that onto my 21" TV that does 1280x1024. Scaling independent of resolution means that your small form becomes idiotic big on larger screens.
Would mean that is becomes useless to buy a screen with a high resolution and lots of space, as everything would look like it is a 640x480 screen.
Your forms should not "look good" based on the screen, they should convey all required information using the space they need. That often means a form that is smaller than the screen. You can use docking and aligments to have the form redraw in a different resolution, filling up extra space as required.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Well , a solution exists , but is too expensive :
Softgroup Components[^]
So I thought maybe there's a technique to implement this
|
|
|
|
|
That is not a solution.
Imagine a presentation on a 42" plasma-screen; each Window behaving neatly, until your app is launched and shows a font that is triple the size of the normal applications, because it feels it needs to "rescale".
If scaling was desired it would be done at the OS-level. Your form has a fixed need in terms of space, and if I have a desktop that has more space, then the form should simply occupy less, not rescale and eat up desktop-space with 48px fonts.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
What you suggest to do with my form that when is displayed on your 42" screen with high resolution looks so small that the text is not readable an nobody understand nothing ?
|
|
|
|
|
My screen.
My machine.
My choice of resolution-setting.
So, if all text is too small, the solution is not in changing a single application, but in changing the system-settings to a suitable resolution for the machines capabilities.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I'm not creating an application that I will use only on my Pc.
Different users with different screen resolution are going to use it.
Users doesn't want to change the screen resolution only for my application.
|
|
|
|
|
satc wrote: I'm not creating an application that I will use only on my Pc. Different
users with different screen resolution are going to use it. As most of us.
satc wrote: Users doesn't want to change the screen resolution only for my application. They don't change the resolution for any application; you application should not be bound to a single resolution. Forms and controls do scale.
Your font should be as big as determined by the systems settings', equal to all other applications, not being resized to match your dimensions. Your "OK" button is going to be rediculously big on future screens with higher resolutions.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Ok , let's take an example
My application on a big screen with high resolution , looks very small and almost unusable.
But Office applications like Word , Excel... are ok.
Why ?
|
|
|
|
|
satc wrote: My application on a big screen with high resolution , looks very small and almost unusable. Means you have a small screen relative to the highest resolution it supports.
satc wrote: But Office applications like Word , Excel... are ok. They aren't, in your terms. They don't resize their buttons to be equal size independent of resolution, those buttons become dang small on my cheap TV, with some unreadable tooltip in them.
So I set the resolution lower until it is readable. The buttons resize as expected, and one can see that there is a bit of (unused) grey area right of the buttons. The largest change is in the document-area; in the case of Word you see that large TextBox take up more space. That means that it simply displays more text if you have a larger screen.
In the case of Excell, you'll see that the amount of rows and columns suddenly increases. They use the additional area to display more information. Even for a complex UI as MS Access, it makes sense.
Take MS Outlook; it is not the "address" bar that is resized; it is just the "body" part that suddenly fills up your form if it is maximized. That's done using docking and alignment.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
And here is a class that I've found , but I think it needs some modifications :
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
Imports System.ComponentModel
Public Class FormResizer
Private f_HeightRatio As New Single()
Private f_WidthRatio As New Single()
Public Sub ResizeForm(ByVal ObjForm As Form, ByVal DesignerWidth As Integer, ByVal DesignerHeight As Integer)
Dim i_StandardHeight As Integer = DesignerHeight
Dim i_StandardWidth As Integer = DesignerWidth
Dim i_PresentHeight As Integer = Screen.PrimaryScreen.Bounds.Height
Dim i_PresentWidth As Integer = Screen.PrimaryScreen.Bounds.Width
f_HeightRatio = CSng(CSng(i_PresentHeight) / CSng(i_StandardHeight))
f_WidthRatio = CSng(CSng(i_PresentWidth) / CSng(i_StandardWidth))
ObjForm.AutoScaleMode = AutoScaleMode.None
ObjForm.Scale(New SizeF(f_WidthRatio, f_HeightRatio))
For Each c As Control In ObjForm.Controls
If c.HasChildren Then
ResizeControlStore(c)
Else
c.Font = New Font(c.Font.FontFamily, c.Font.Size * f_HeightRatio, c.Font.Style, c.Font.Unit, CByte(0))
End If
Next
ObjForm.Font = New Font(ObjForm.Font.FontFamily, ObjForm.Font.Size * f_HeightRatio, ObjForm.Font.Style, ObjForm.Font.Unit, CByte(0))
End Sub
Public Sub ResizeControlStore(ByVal objCtl As Control)
If objCtl.HasChildren Then
For Each cChildren As Control In objCtl.Controls
If cChildren.HasChildren Then
ResizeControlStore(cChildren)
Else
cChildren.Font = New Font(cChildren.Font.FontFamily, cChildren.Font.Size * f_HeightRatio, cChildren.Font.Style, cChildren.Font.Unit, CByte(0))
End If
Next
objCtl.Font = New Font(objCtl.Font.FontFamily, objCtl.Font.Size * f_HeightRatio, objCtl.Font.Style, objCtl.Font.Unit, CByte(0))
Else
objCtl.Font = New Font(objCtl.Font.FontFamily, objCtl.Font.Size * f_HeightRatio, objCtl.Font.Style, objCtl.Font.Unit, CByte(0))
End If
End Sub
End Class
|
|
|
|
|
Linking to commercial components looks like spam. I suggest you edit your message and remove the link.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry , with that link I'm just confirming that a solution exists but it's too expensive. Without giving the link , how can I express what I want ?
|
|
|
|
|
I have an xml file that I am loading into a datagridview. Pretty simple and loads with no problem.
<?xml version="1.0" encoding="utf-8"?>
<!--Project Time Tracking-->
<TimeTracking>
<Ticket Client="150-338" Code="Overview" Call="33685" Start_Time="1/12/2015 10:04:56 AM" Stop_Time="1/12/2015 2:09:04 PM" TimeNote="">04:04:08</Ticket>
<Ticket Client="150-310" Code="Documents" Call="32201" Start_Time="11/20/2014 11:42:20 AM" Stop_Time="11/20/2014 3:21:04 PM" TimeNote="install and test 1099 again internally.">04:39:44</Ticket>
<Ticket Client="609-327" Code="Misc Implementation" Call="34453" Start_Time="2/20/2015 10:15:36 AM" Stop_Time="2/20/2015 10:45:36 AM" TimeNote="Help with docusign and discuss Trust account">00:30:00</Ticket>
</TimeTracking>
Now, as you can see there is a Start_Time and Stop_Time column. Like tons of other folks, I am trying to sort the date columns Descending with no luck. When I use the grid to sort, or add my own programmatic sorting, it does not sort in date order, but in text format. From what I have read, this is because the data is being seen as a string and not a date.
Below is my simple code to load the xml
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
Dim myXMLTime As String = "C:\myBSG\myBSGTimeclock.xml"
DataGridView2.Columns.Clear()
DataGridView2.Rows.Clear()
dsTime.ReadXml(myXMLTime)
DataGridView2.DataSource = dsTime
DataGridView2.DataMember = "Ticket"
DataGridView2.Sort(DataGridView2.Columns(6), System.ComponentModel.ListSortDirection.Descending)
End Sub
I have played with literally hundreds of examples I have found online which attempt to address this problem with no success. Some have loaded the data into a datatable or a Dataset in an attempt to sort it there and then use that to load the datagridview. Either they did not work or were to complex for me to understand as a beginner. I cannot imagine that this could be THAT difficult as there have to be plenty of folks that need to sort by date in the Datagridview.
I need to sort load the grid with ReadXML and then be able to modify as necessary and write it back to xml using WriteXML
Any help that could be offered would be greatly appreciated!
Dan
Dan Chapin
|
|
|
|
|
How is the data being loaded and into what data structure? How the data is represented affects how you're going to sort it. If it's stored in memory as strings, there's your problem.
|
|
|
|
|
Unfortunately, there's no easy way to do this, because your dates are not in the standard XML date/time format[^], and your XML doesn't include a schema.
You'll need to read the XML into a temporary table, and then manually copy the rows to a table with the correct data types for the columns.
Something like this should work:
Dim dsTemp As New DataSet()
dsTemp.ReadXml(myXMLTime)
Dim dsTime As DataSet = dsTemp.Clone()
Dim table As DataTable = dsTime.Tables(0)
Dim startTimeColumn As DataColumn = table.Columns("Start_Time")
Dim stopTimeColumn As DataColumn = table.Columns("Stop_Time")
startTimeColumn.DataType = GetType(DateTime)
stopTimeColumn.DataType = GetType(DateTime)
Dim formatProvider As IFormatProvider = System.Globalization.CultureInfo.InvariantCulture
For Each row As DataRow in dsTemp.Tables(0).Rows
Dim values As Object() = row.ItemArray
Dim time As String = DirectCast(values(startTimeColumn.Ordinal), String)
values(startTimeColumn.Ordinal) = DateTime.Parse(time, formatProvider)
time = DirectCast(values(stopTimeColumn.Ordinal), String)
values(stopTimeColumn.Ordinal) = DateTime.Parse(time, formatProvider)
table.Rows.Add(values)
Next
DataGridView2.DataSource = dsTime
DataGridView2.DataMember = "Ticket"
DataGridView2.Sort(DataGridView2.Columns(startTimeColumn.Ordinal), System.ComponentModel.ListSortDirection.Descending)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
pls i have a some textbox named ram size and i have a value in a combo box like rack, personal computer, servers and i want when i select rack from the combo box, the ram size text box should be set to readonly.
|
|
|
|
|
OK, so what part of this are you having a problem with?
Is it handling the SelectedItemChanged event of the ComboBox or setting the ReadOnly property of the TextBox to True?
|
|
|
|
|
setting the ReadOnly property of the TextBox to True?
|
|
|
|
|