Google Mobile Ads

Tuesday, August 28, 2012

Textbox içine sadece alphanumeric karakterler girilmesini sağlayan kod.


Private Sub textBox_KeyPress(........
   Dim cInvalidChars() As Char = {"~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "-", "=", "+", "{", "[", "}", "]", "|", "\", ":", ";", """", "'", "<", ",", ">", ".", "?", "/"}
   Dim result As Boolean = False
   result = cInvalidChars.Contains(e.KeyChar)
   If result Then
          e.Handled = True
   End If
End Sub

DataGridView de bir hücreye odaklanmak.

DataGridView1.CurrentCell = DataGridView1.Item("ColumnName", rowIndex)


How to focus a cell in datagridview in vb.net

Monday, August 13, 2012

VB.Net'te Combobox içine Value ve Text içeriklerini eklemek

ComboBoxItem text ve value değerlerini alan class ımız. Kodunu aşağıda bulabilirsiniz.


'--------------------------------------------------------------
            Dim lstMonths As New List(Of ComboBoxItem)

            lstMonths.Add(New ComboBoxItem("January", 1))
            lstMonths.Add(New ComboBoxItem("February", 2))
            lstMonths.Add(New ComboBoxItem("March", 3))
            lstMonths.Add(New ComboBoxItem("April", 4))
            lstMonths.Add(New ComboBoxItem("May", 5))
            lstMonths.Add(New ComboBoxItem("June", 6))
            lstMonths.Add(New ComboBoxItem("July", 7))
            lstMonths.Add(New ComboBoxItem("August", 8))
            lstMonths.Add(New ComboBoxItem("September", 9))
            lstMonths.Add(New ComboBoxItem("October", 10))
            lstMonths.Add(New ComboBoxItem("November", 11))
            lstMonths.Add(New ComboBoxItem("December", 12))

            'cbMonths is a combobox

            cbMonths.DataSource = lstMonths
            cbMonths.DisplayMember = "Text"
            cbMonths.ValueMember = "Value"

'--------------------------------------------------------------


Friday, August 10, 2012

10 Tips For Designing A Usable Interface

Designing a usable interface is about the skills of the designer as well as how they are able to teach the user how to interact with the site. Here are ten tips we have used to design user interfaces:
  1. Know your target audience – This is the first question to ask and answer before any designs are even contemplated. Knowing who you’re designing for enables you to make the final product useful.
  2. Make sure your design flows – Like a staircase, every step leads the user to where s/he wants to go. Having the right flows keeps the user from wondering where they are and how they got there.
  3. Easy navigation – Knowing where they are and where to go next to complete the task is one of the basic elements of UX.
  4. Recovery from errors  – Minimize the negative effect by creating a flow that allows users to quickly recover from errors and find ways around it.
  5. Put first things first – This is not only the first rule for highly effective people but it’s also a great guide for highly effective user interface design. Putting all elements into a hierarchy allows the user to quickly find whats/he is looking for, which in turn makes UI intuitive for them.
  6. Think usability, not just simplicity – In a previous post, we questioned whethersimplicity is critical for usable design. Simplicity for simplicity sake is useless.  Usable design creates a positive user experience by using simplicity to minimize the learning curve and getting rid of all obstacles between the use and the goal.
  7. Keep text simple – For whatever content is on the site, make sure that it’s easy to understand and won’t have the user consulting the dictionary. Keep content clear, concise, and understandable.
  8. Less UI = better UX– Extraneous elements cause the user to lose focus. Good design is clear, concise and invisible because it is felt more than it’s seen.
  9. Put everything in its place – The key here is relevance. Unless there is a good reason not to, UI should follow existing user mental models. Having elements in the expected place creates consistency and builds trust with the user.
  10. Use colors wisely – Colors should be used to emphasize functionality of elements. It would help overall UI intuitiveness and help users quickly find desired functionality.

Wednesday, August 1, 2012

VB.NET : OpenFileDialog ile dosya adı ve dizin yoluna ulaşmak.

OpenFileDialog ile seçilen dosyanın adına ve dizin yoluna ulaşmak için aşağıdaki kod kullanılmaktadır.

Dosya Adı için : System.IO.Path.GetFileName(openFileDialog.FileName)

Dizin Yolu için : System.IO.Path.GetDirectoryName(openFileDialog.FileName)



How to get File Name and File Path from OpenFileDialog.

Wednesday, July 18, 2012

VB.Net'te Datatable'ı Excel'e Aktaran Metod

VB.Net'te Excel Interop kullanarak bir datatable ın Excel'e aktarılmasını sağlayan metodumuz aşağıdaki gibidir. Metodu kullanabilmeniz için projenize Microsoft.Office.Interop.Excel referansını eklemeniz gerekmektedir.


    Private Sub DatatableToExcel(ByVal dtTemp As DataTable)
        Try
            Dim myCultureInfo As CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
            Dim _excel As New Microsoft.Office.Interop.Excel.Application
            Dim wBook As Microsoft.Office.Interop.Excel.Workbook
            Dim wSheet As Microsoft.Office.Interop.Excel.Worksheet


            folderBrowser.ShowDialog()
            If folderBrowser.SelectedPath <> "" Then
                System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-us")
                wBook = _excel.Workbooks.Add()
                wSheet = wBook.ActiveSheet()


                Dim dt As System.Data.DataTable = dtTemp
                Dim dc As System.Data.DataColumn
                Dim dr As System.Data.DataRow
                Dim colIndex As Integer = 0
                Dim rowIndex As Integer = 0


                For Each dc In dt.Columns
                    colIndex = colIndex + 1
                    _excel.Cells(1, colIndex) = dc.ColumnName
                Next


                For Each dr In dt.Rows
                    rowIndex = rowIndex + 1
                    colIndex = 0
                    For Each dc In dt.Columns
                        colIndex = colIndex + 1
                        _excel.Cells(rowIndex + 1, colIndex) = dr(dc.ColumnName)
                    Next
                Next


                wSheet.Columns.AutoFit()
                Dim strFilePath As String = folderBrowser.SelectedPath + "\"
                Dim strFileName As String = "Sorgu_" + Date.Now.Year.ToString() + Date.Now.Month.ToString() + Date.Now.Day.ToString() + Date.Now.Second.ToString() + ".xlsx"
                If System.IO.File.Exists(strFilePath + strFileName) Then
                    System.IO.File.Delete(strFilePath + strFileName)
                End If


                wBook.SaveAs(strFilePath + strFileName)
                wBook.Close()
                _excel.Quit()


                System.Threading.Thread.CurrentThread.CurrentCulture = myCultureInfo
                MsgBox("Sorgu Sonuç Ekranı Excel'e Aktarılmıştır." + vbCrLf + "Dosyanın Kaydedildiği Yol: " + strFilePath + vbCrLf + "Dosya Adı: " + strFileName)
            End If
        Catch ex As Exception


        End Try
    End Sub

LinkWithin

Related Posts Plugin for WordPress, Blogger...