Đăng nhập | Đăng ký

Danh sách thành viên | Cá nhân | Nhà đất, bất động sản

Diễn đàn    Window Form programming    Tạo style trong datagrid của winform

Thành viênNội dung
dotnetvn

dotnet.vn
72  bài
15-06-2008 08:26:57
Public Shared Function CreateStyle() As DataGridTableStyle
Dim mStyle As New DataGridTableStyle
With mStyle
.HeaderFont = New Font("Arial", 9, FontStyle.Bold)
.HeaderBackColor = Color.LightBlue
.AlternatingBackColor = Color.Cornsilk
.PreferredRowHeight = 24
.AllowSorting = True
End With

Return mStyle
End Function
Public Shared Function CreateCollumnTextBoxStyle(ByVal mapname As String, _
ByVal header As String, ByVal wid As Integer, ByVal nulltext As String, _
ByVal align As HorizontalAlignment)

Dim colStyle As New DataGridTextBoxColumn
With colStyle
.MappingName = mapname
.HeaderText = header
.Width = wid
.NullText = nulltext
.Alignment = align
End With

Return colStyle
End Function
Public Shared Function CreateCollumnCheckBoxStyle(ByVal mapname As String, _
ByVal header As String, ByVal wid As Integer)

Dim colStyle As New DataGridBoolColumn
With colStyle
.MappingName = mapname
.HeaderText = header
.Width = wid
End With

Return colStyle
End Function
 
dotnetvn

dotnet.vn
72  bài
15-06-2008 08:27:55
Để hiển thị nó lên dùng cái này

Private Sub FormatGrid()
Dim style As New DataGridTableStyle
style = USF.CreateStyle()

Dim colStyle1 As New DataGridTextBoxColumn
colStyle1 = USF.CreateCollumnTextBoxStyle("Ten_khoa", "Khoa", 80, "", HorizontalAlignment.Left)
Dim colStyle2 As New DataGridTextBoxColumn
colStyle2 = USF.CreateCollumnTextBoxStyle("Ma_gv", "Mã GV", 50, "", HorizontalAlignment.Left)
Dim colStyle3 As New DataGridTextBoxColumn
colStyle3 = USF.CreateCollumnTextBoxStyle("Ho_ten", "Tên GV", 160, "", HorizontalAlignment.Left)

style.GridColumnStyles.AddRange(New DataGridColumnStyle() {colStyle1, colStyle2, colStyle3})
dg.TableStyles.Add(style)
End Sub
 
dotnetvn

dotnet.vn
72  bài
15-06-2008 08:29:11
Cái formảtgid chỉ cần dùng 1 lần đầu tiên khi form load, còn muốn hiển thị lại dữ liệu cũng như lần đầu hiển thị dữ liệu khi form load thì dùng cái này

Private Sub Reload()
Try
Dim strSQL As String = "SELECT GIAO_VIEN.*, KHOA.Ten_khoa " _
+ " FROM GIAO_VIEN INNER JOIN " _
+ " KHOA ON GIAO_VIEN.ID_khoa = KHOA.ID_khoa" _
+ " ORDER BY Ho_ten"
Dim dt As DataTable = UDB.SelectTable(strSQL)

dt.DefaultView.AllowDelete = False
dt.DefaultView.AllowEdit = False
dt.DefaultView.AllowNew = False
dg.DataSource = dt.DefaultView
Catch ex As Exception
UCommon.ThongBao(ex.Message)
End Try
End Sub
 
dotnetvn

dotnet.vn
72  bài
15-06-2008 08:30:04
Muốn moi dữ liệu mỗi khi bấm vào 1 dòng nào đó của datagrid ra thì dùng cái hàm này
------------------
Private Sub SetUI(ByVal idx As Integer)
Try
Dim dv As DataView = dg.DataSource
Me.ID_gv = CInt(dv(idx)("ID_gv"))
txtHoTen.Text = dv(idx)("Ho_ten").ToString()
txtMa.Text = dv(idx)("Ma_gv").ToString()
dtpNgaysinh.Value = CDate(dv(idx)("Ngay_sinh"))
txtQue.Text = dv(idx)("Que_quan").ToString()
txtTen.Text = dv(idx)("Ten").ToString()
cboBomon.SelectedValue = CInt(dv(idx)("ID_bm"))
cboCapbac.SelectedValue = CInt(dv(idx)("ID_capbac"))
cboChucdanh.SelectedValue = CInt(dv(idx)("ID_chucdanh"))
cboChucvu.SelectedValue = CInt(dv(idx)("ID_chucvu"))
cboDantoc.SelectedValue = CInt(dv(idx)("ID_dantoc"))
cboHocham.SelectedValue = CInt(dv(idx)("ID_hocham"))
cboHocvi.SelectedValue = CInt(dv(idx)("ID_hocvi"))
cboKhoa.SelectedValue = CInt(dv(idx)("ID_khoa"))
If (CBool(dv(idx)("Nam")) = True) Then
radNam.Checked = True
Else
radNu.Checked = True
End If
Catch ex As Exception
End Try
End Sub

-----------------
và đây nữa
-----------------
Private Sub dg_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dg.CurrentCellChanged
btnThem.Enabled = False
Dim idx As Integer = dg.CurrentRowIndex
If idx < 0 Then Return
Me.SetUI(idx)
End Sub
--------------------
tý quên
 
chinh


1  bài
11-10-2008 01:34:49
 
kimlong008


25  bài
16-10-2008 07:37:27
hì hì !! xin lỗi chút nha !! trên thực tế ở phần properties nó cho phép chỉnh sữa lưới của win form hay lưới của web rồi !!! chẳng qua do mọi người ko chịu tìm hiểu có video hướng dẫn nhưng bằng english để bữa nào rảnh nén lại gửi cho mọi người coi !!
---
 
kaka

Thiên thần Kaka
36  bài
07-12-2008 04:07:55
nén luôn đê toàn thấy nói chả thấy làm gì ?
---
 

Chủ đề gần đây :

Cùng loại :

 
Tên file Người đăng Ngày Lượt
vspforum.zip
Ma nguon vspforum ngay xua
aspnet 4/18/2023 6:38:37 AM 6
pdfjs.rar
pdfjs 2017 : hiển thị tốt trên iphone 11, 12, 13 không lỗi, bản 2012 sẽ lỗi trên iphone
aspnet 6/21/2022 11:52:48 AM 2
pdfjs2.rar
Xem file pdf bằng viewer.hml cua pdfjs (thư viện chuẩn mozilla) 2012. https://mozilla.github.io/pdf.js/getting_started/#download có thể download bản prebuild tại đây
aspnet 6/21/2022 11:52:04 AM 2
runner.zip
using three.js, orbitcontrol to view an object move random on map. Di chuyển 1 đồ vật ngẫu nhiên trên bản đồ, sử dụng với demo nhân viên di chuyển trong văn phòng. Toàn js download về là chạy
aspnet 12/5/2019 5:55:14 PM 0
gmap.zip
google map + marker
aspnet 7/17/2019 2:25:05 PM 1
vinsmarthomeservice.zip
java post json to api, use AsyncTask, event listener
aspnet 7/9/2019 5:00:10 PM 1
fblogin.zip
Login facebook bang javascript SDK
aspnet 7/9/2019 9:16:37 AM 0
autocomplete-location.zip
autocomplete location geo from google place, html + js
aspnet 7/4/2019 4:37:55 PM 2
WebAPI.zip
api for android access db (v1.0.0)
aspnet 7/4/2019 9:14:17 AM 8
KydientuPdf.zip
Ky dien tu file PDF su dung itextsharp
aspnet 4/9/2019 3:30:37 PM 9
GooglePlusLogin.zip
Login Google Plus account, C#, web asp.net ver2.0. Simple connect google APIs. Send key, get token, get full account info
aspnet 6/1/2018 10:41:12 AM 11
WebApplication1.rar
Sample su dung thuat toan ma hoa tripDES, co khoa bi mat (privateKey)
aspnet 3/30/2018 10:06:35 PM 8
NETMdbToolsTestApp.rar
dotNet MdbTools for Access 2003/2007/2016 without Microsoft Jet Engine, source C#, https://www.codeproject.com/Articles/283626/MsAccess-MdbTools-with-MFC-and-NET
aspnet 3/26/2018 11:43:16 PM 1
Cryptography_MD5_TriDES_src.zip
Thuật toán mã hóa 2 chiều TriDES, gồm Encrypt và Decrypt, aspnet 2.0
aspnet 3/22/2018 11:20:44 AM 3
mvc.rar
sample project MVC on C#
aspnet 3/20/2018 9:25:36 AM 9
EduPortal.rar
Edu portal frame work for VB.NET
aspnet 3/14/2018 12:00:41 AM 13
AutoEntity.rar
Gencode vb.net visual studio 2015. dotnet v2.0
aspnet 3/13/2018 11:59:16 PM 2
GenCode.rar
Gencode XML, XSLT, Info, DAL .. engine enterprise for quick app database
aspnet 2/5/2018 9:37:28 AM 9
DataXml.rar
Read DB from SQL to XML file, Convert string TCVN to Unicode
aspnet 1/29/2018 2:15:45 PM 4
DesktopModules.rar
Module quản lý tin tức, CMS, quản lý nhóm tin trên dotnetnuke 6.x
aspnet 3/7/2013 4:47:49 PM 1714
CODERVN.NET
Công ty cổ phần công nghệ và dịch vụ AWAS
Công ty cổ phần công nghệ và dịch vụ AWAS, cổng thông tin, chính phủ điện tử, phần mềm quản lý điểm, quản lý sinh viên, http://awas.vn, http://awas.com.vn, phần mềm ứng dụng, dịch vụ công trực tuyến, thiết kế website, thiet ke web, thiết kế web, điện lực, phần mềm quản lý đào tạo, cao đẳng, đại học,cổng thông tin tích hợp, cổng thông tin điện tử, webportal, thư viện điện tử, electric library, library online, email, web, quản lý quan hệ khách hàng, CRM, dịch vụ công trực tuyến, phần mềm hành chính một cửa,