Hi,
No problem, let me now if it works.
Hi,
No problem, let me now if it works.
Hi,
Add a label in designtime and place it above the datetimepicker, just like Codeorder showed.
In the properties of the label set the text: - Please Select Date - and the textalign = center.
That's all.
Hi,
In the properties of the textboxes you doesn't want the focus set Tabstop = False
For the textbox set Tabindex = 0
Hi,
First the proper link, look here.
I think:
'textBox1.Text=fdlg.FileName
is a typo.
Try this:
Dim fdlg As New OpenFileDialog
fdlg.Title = "C# Corner Open File Dialog"
fdlg.InitialDirectory = "c:\"
fdlg.Filter = "Word Documents (*.Doc)|*.Doc|txt files (*.txt)|*.txt|All files (*.*)|*.*"
fdlg.FilterIndex = 2
fdlg.RestoreDirectory = True
If fdlg.ShowDialog() = DialogResult.OK Then
TextBox1.Text = fdlg.FileName
fdlg.OpenFile()
End If
Hi,
Did you had some errors?
How did you used that part of code?
...
Hi,
Create a form and change in the properties:
borderstyle = Fixedtoolwindow
Controlbox = False
Startposition= centerscreen
Then add the buttons you need for your application.
Just a thought :)
Hi,
A string containing the column name followed by "ASC"(ascending) or "DESC"(descending) will change the datatable order.
The columns are sorted ascending by default.
Hi,
You can try something like this:
Me.DataGridView1.Rows.Insert(0, value1, value2) ' values you entered
Didn't tested it
Hi,
You should try something like this:
Dim item As ListItem
For Each item In ListView1.ListItems
If item.Selected = False Then
'do your stuff here
End If
Next
Hi,
Mark this thread as solved when it answered your problem.
Hi,
For your second question, use this in a button event:
System.diagnostics.Process.Start("shutdown", "-s")
' Will cause the computer to shutdown
Dear Sir/Madam,
I have two form in my application form1 and form2. Here, i want to show the form2 from form1 by using a button. And i want to reverse back to my form1 from form2 using same technique. But i want to close form1 (Not visible=false or hide) after loading form2 and same thing in reverse back also.
I have tried like this....
'for from1 form2.show() 'form1.close ' not accepted me.close
In my above code whole application is closing.
'for form2 form1.show() me.close()
Here it is working in form2
I want to know that can we close our current form after showing another form? Please guide me.
Hi,
You just need to go to the properties of your application and set:
Shutdownmode = When last form closes
Your application will only close when last form closes.
Hi,
You should try something like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If CheckBox1.Checked = False Or TextBox1.Text = "" Then
MsgBox("Error, You forgot something")
Else
MsgBox("Progressbar coding goes here")
End If
End Sub
thanks animal mother. it paints tabpage header. but it doesnt paint remaining part of the tab control... is ther any solution to this..
Hi Ashu26,
You can do it like this;
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
'Firstly we'll define some parameters.
Dim CurrentTab As TabPage = TabControl1.TabPages(e.Index)
Dim ItemRect As Rectangle = TabControl1.GetTabRect(e.Index)
Dim FillBrush As New SolidBrush(Color.RoyalBlue)
Dim TextBrush As New SolidBrush(Color.White)
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center
'If we are currently painting the Selected TabItem we'll
'change the brush colors and inflate the rectangle.
If CBool(e.State And DrawItemState.Selected) Then
FillBrush.Color = Color.White
TextBrush.Color = Color.RoyalBlue
TabPage1.BackColor = Color.LightBlue ' change the backcloor of your tabpage1
TabPage2.BackColor = Color.LightGreen ' Change backcolor of tabpage2
ItemRect.Inflate(2, 2)
End If
'Set up rotation for left and right aligned tabs
If TabControl1.Alignment = TabAlignment.Left Or TabControl1.Alignment = TabAlignment.Right Then
Dim RotateAngle As Single = 90
If TabControl1.Alignment = TabAlignment.Left Then RotateAngle = 270
Dim cp As New PointF(ItemRect.Left + (ItemRect.Width \ 2), ItemRect.Top + (ItemRect.Height \ 2))
e.Graphics.TranslateTransform(cp.X, cp.Y)
e.Graphics.RotateTransform(RotateAngle)
ItemRect = New Rectangle(-(ItemRect.Height \ 2), -(ItemRect.Width \ 2), ItemRect.Height, ItemRect.Width)
End If
'Next we'll paint the TabItem with our Fill Brush
e.Graphics.FillRectangle(FillBrush, ItemRect)
'Now draw the text.
e.Graphics.DrawString(CurrentTab.Text, e.Font, TextBrush, RectangleF.op_Implicit(ItemRect), sf)
'Reset any Graphics rotation
e.Graphics.ResetTransform()
'Finally, we should Dispose of our brushes.
FillBrush.Dispose()
TextBrush.Dispose()
End Sub
Hi,
To let the code that Animal Mother provided work.
You need to change in the properties of that Tabcontrol the Drawmode = OwnerDrawFixed
it works for the final result, but when you click the dropdown button it shows you day and month, I want to pick years only, how can I do that
thanks
Hi,
If you want only a dropdown with years to select without any days and months, then you doesn't need a datetimepicker but only a combobox completed with years.
Hi,
If you'll using this Powerpointviewer ActiveXcontrol then it's like any other control in your application.
Hi,
Before I posted this code I've tested it without any other key.
So, When you type "O" the Msgbox will be showing the message.
Hi,
When you need Crystal Reports then you need Visual Studio Standard or Higher. It doesn't work with express.
Hi,
Go to the properties of your button and use this text: &Open and this name: btnOpen
You will see in the designer the text appear in the button like this: Open
Now, try this part of code:
Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
MsgBox("You used the shortcut key")
End Sub
Hi chibex64,
Your code only shows a randomvalue and not the datetime.minute or datetime.year.
You should do it like this:
'declare variables
Dim randomvalue As New Random 'create random object
Dim randomhold As Integer
'generate random number
For i As Integer = 0 To 9999
randomhold = randomvalue.Next(1, 9999)
txtUserId.Text = randomhold & " " & DateTime.Now.Minute & " " & DateTime.Now.Year
Next
Hi,
When you first open up a project written in VS 2008 inside VS 2010 it will normaly prompt you to upgrade the project. What this actually does is update the project (.vbproj) and solution .(sln) files to be compatible with VS 2010.
Did you tryed that?
Hi,
You could try to set AutoGenerateColumns = off .
Hi,
You could mark this thread as solved.
Hi,
You can try something like this:
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged, _
RadioButton2.CheckedChanged
If RadioButton1.Checked Then
MsgBox("You clicked Radiobutton1")
End If
If RadioButton2.Checked Then
MsgBox("You clicked Radiobutton2")
End If
End Sub
Hi,
If that solved your problem, mark this thread as solved.
Hi,
You can try something like this:
EmailTextBox.Text = EmailGridView.Item(1, DataGridView1.SelectedRows(0).Index).Value
Hi,
Something like this;
Private Sub NameTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles NameTextBox.KeyDown
If e.KeyCode = Keys.Back Then
MessageBox.Show("You hit the Backkey")
End If
If e.KeyCode = Keys.CapsLock Then
MsgBox("You hit the Capslockkey")
End If
End Sub
Hi,
can anyone guide me on how to check the server DateTime when the application launch. i want to make sure the user PC has the same DateTime as server when the user use the application. Reason being is some user may tend to change their DateTime backward and it causes a major confusion when it update in the server database.
Please guide me !
Hi,
I'm not sure about how to help you, but you can find some explanation about serverdatetimes, here.
Hi,
You can give the checkboxtext the same text as the listviewheader.
What you can do is the use a Datagridview instead and there you can add checkboxes.
Hi,
You can't add a Checkbox into the listview header, but you can add a checkbox into the listview header and use this ccde to use it.
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
For Each lvitem As ListViewItem In Me.ListView1.Items
If lvitem.Checked = False Then
lvitem.Checked = True
Else
lvitem.Checked = False
End If
Next
End Sub
Hi,
Here's an example how to do it:
Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint
'--- Start printing at the start of the string
mStringPos = 0
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
'--- Setup graphics context
Dim fnt As New Font("Arial", 10)
e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
'--- Calculate the number of characters that fit inside the margins
Dim area As SizeF = New SizeF(e.MarginBounds.Width, e.MarginBounds.Height)
Dim lines, chars As Integer
e.Graphics.MeasureString(PrintText.Substring(mStringPos), fnt, area, _
StringFormat.GenericTypographic, chars, lines)
'--- Print the amount of text that fits inside the margins
Dim rc As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)
e.Graphics.DrawString(PrintText.Substring(mStringPos, chars), fnt, _
Brushes.Black, rc, StringFormat.GenericTypographic)
'--- Advance print position by <chars>
mStringPos += chars
'--- We'll need another page if not all characters got printed
e.HasMorePages = mStringPos < PrintText.Length
'--- Cleanup
fnt.Dispose()
End Sub
Hi,
You can delete rows by first selecting the rows and then pressing the Delete key. If you may want to confirm the deletion with the user before deleting them. You can do this with the UserDeletingRow event:
Private Sub DataGridView1_UserDeletingRow( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms. _
DataGridViewRowCancelEventArgs) _
Handles DataGridView1.UserDeletingRow
If (Not e.Row.IsNewRow) Then
Dim response As DialogResult = _
MessageBox.Show( _
"Are you sure you want to delete this row?", _
"Delete row?", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button2)
If (response = DialogResult.No) Then
e.Cancel = True
End If
End If
End Sub