PDA

View Full Version : شماره گذاری دیتاگرید ویو



omid-vbAuto
دوشنبه 15 آذر 1389, 15:29 عصر
با سلام دوستان

ما چطوری می تونیم یک شماره گذاری برای قسمتی که در کادر قرمز رنگ مشخص کردم انجام بدیم؟مانند ستون اول.


63184
http://barnamenevis.org/images/misc/pencil.png

ali_najari
دوشنبه 15 آذر 1389, 15:54 عصر
دوست عزيز اين بحث قبلا پاسخ داده شده!
حتما جستوجو كنيد!

omid-vbAuto
دوشنبه 15 آذر 1389, 15:59 عصر
دوست عزيز اين بحث قبلا پاسخ داده شده!
حتما جستوجو كنيد!

خوب شد که گفتین جستجو کن .مهندس دکمه جستجو ی سایت باتریش تموم شده .
آقا من خودم می خواستم جستجو کنم ولی اصلا وعبدا به جستجو نمیره!!! (فکر کنم ایراد داره )اگه نه که بما روش جستجو رو بفرمائید.

بعدش هم لطف کنید لینک اون صفحه که بحث شده رو بفرمائید.

ali_najari
دوشنبه 15 آذر 1389, 16:27 عصر
دوست عزيز من وقتي ديدم كه جستوجو غير فعال هست يه نمونه براتون آماده كردم كه ميتونيد ازش استفاده كنيد البته توي خود MSDN هست!



Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEvent Args) Handles DataGridView1.CellPainting
If e.RowIndex >= 0 AndAlso e.ColumnIndex = -1 Then
Dim newRect As New Rectangle(e.CellBounds.X + 1, e.CellBounds.Y + 1, _
e.CellBounds.Width - 4, e.CellBounds.Height - 4)
Dim backColorBrush As New SolidBrush(e.CellStyle.BackColor)
Dim gridBrush As New SolidBrush(Me.DataGridView1.GridColor)
Dim gridLinePen As New Pen(gridBrush)
Try
e.Graphics.FillRectangle(backColorBrush, e.CellBounds)
e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, _
e.CellBounds.Bottom - 1, e.CellBounds.Right - 1, _
e.CellBounds.Bottom - 1)
e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1, _
e.CellBounds.Top, e.CellBounds.Right - 1, _
e.CellBounds.Bottom)
e.Graphics.DrawString(e.RowIndex + 1, e.CellStyle.Font, _
Brushes.Red, e.CellBounds.X + 2, e.CellBounds.Y + 2, _
StringFormat.GenericDefault)
e.Handled = True
Finally
gridLinePen.Dispose()
gridBrush.Dispose()
backColorBrush.Dispose()
End Try
End If
End Sub


63187

omid-vbAuto
دوشنبه 15 آذر 1389, 18:55 عصر
دوست عزيز من وقتي ديدم كه جستوجو غير فعال هست يه نمونه براتون آماده كردم كه ميتونيد ازش استفاده كنيد البته توي خود MSDN هست!



PrivateSub DataGridView1_CellPainting(ByVal sender AsObject, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEvent Args) Handles DataGridView1.CellPainting
If e.RowIndex >= 0 AndAlso e.ColumnIndex = -1 Then
Dim newRect AsNew Rectangle(e.CellBounds.X + 1, e.CellBounds.Y + 1, _
e.CellBounds.Width - 4, e.CellBounds.Height - 4)
Dim backColorBrush AsNew SolidBrush(e.CellStyle.BackColor)
Dim gridBrush AsNew SolidBrush(Me.DataGridView1.GridColor)
Dim gridLinePen AsNew Pen(gridBrush)
Try
e.Graphics.FillRectangle(backColorBrush, e.CellBounds)
e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, _
e.CellBounds.Bottom - 1, e.CellBounds.Right - 1, _
e.CellBounds.Bottom - 1)
e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1, _
e.CellBounds.Top, e.CellBounds.Right - 1, _
e.CellBounds.Bottom)
e.Graphics.DrawString(e.RowIndex + 1, e.CellStyle.Font, _
Brushes.Red, e.CellBounds.X + 2, e.CellBounds.Y + 2, _
StringFormat.GenericDefault)
e.Handled = True
Finally
gridLinePen.Dispose()
gridBrush.Dispose()
backColorBrush.Dispose()
EndTry
EndIf
EndSub


63187









مرسی مهندس دست طلا

ولی یکم کد نویسیش زیاد نیست؟

بعدش هم من اگه بخوام بجای عدد یک رشته بنویسم چکار کنم؟حدالمقدور با کدهای کم.

ali_najari
دوشنبه 15 آذر 1389, 22:28 عصر
دوست عزیز شما وقتی بخوای روی RowHeader بنویسی راه دیگه ای نست و مجبوری از همین راه استفاده کنید

اگر میخواهید متن بنویسید فقط کافیه که اون قسمت اخر که نوشته e.Graphics.DrawString بجای e.rowindex+1 متن دلخواهتون رو بزارید!

omid-vbAuto
دوشنبه 15 آذر 1389, 23:02 عصر
دوست عزیز شما وقتی بخوای روی RowHeader بنویسی راه دیگه ای نست و مجبوری از همین راه استفاده کنید

اگر میخواهید متن بنویسید فقط کافیه که اون قسمت اخر که نوشته e.Graphics.DrawString بجای e.rowindex+1 متن دلخواهتون رو بزارید!

مهندس ازتون ممنونم.