نمایش نتایج 1 تا 2 از 2

نام تاپیک: قراردادن آیکون کنار متن در گریدویو

  1. #1

    قراردادن آیکون کنار متن در گریدویو

    سلام دوستان چگونه با کلید کردن در سلول مد نظر در گریدویو آیکون مورد نظر ظاهر شود و امکان درج اطلاعات هم در کنار آیکون وجود داشته باشد یعنی چگونه می توان آیکون را همراه با متن داخل سلول گریدویو قرار داد با تشکر و سپاس

  2. #2
    کاربر دائمی آواتار پرستو پارسایی
    تاریخ عضویت
    آبان 1392
    محل زندگی
    تهران
    پست
    458

    نقل قول: قراردادن آیکون کنار متن در گریدویو

    ' Create a new button column and add it to the DataGridViewPrivate buttonColumn As New DataGridViewButtonColumn()
    buttonColumn.HeaderText = "Actions"
    buttonColumn.Text = "Edit"
    buttonColumn.Name = "EditButton"
    buttonColumn.UseColumnTextForButtonValue = True
    dataGridView1.Columns.Add(buttonColumn)


    ' Handle the CellPainting event to add an icon to the cell
    private void dataGridView1_CellPainting(Object sender, DataGridViewCellPaintingEventArgs e)
    If e.ColumnIndex = dataGridView1.Columns("EditButton").Index AndAlso e.RowIndex >= 0 Then
    e.Paint(e.CellBounds, DataGridViewPaintParts.All)


    Dim icon = My.Resources.EditIcon ' Replace with your desired icon
    Dim iconWidth = icon.Width
    Dim iconHeight = icon.Height
    Dim cellHeight = e.CellBounds.Height
    Dim cellWidth = e.CellBounds.Width


    ' Calculate the position of the icon and text
    Dim iconX = e.CellBounds.Left + (cellWidth - iconWidth) \ 2
    Dim iconY = e.CellBounds.Top + (cellHeight - iconHeight) \ 2
    Dim textX = e.CellBounds.Left + (cellWidth - e.Graphics.MeasureString("Edit", e.CellStyle.Font).Width) \ 2
    Dim textY = e.CellBounds.Top + (cellHeight - e.CellStyle.Font.Height) \ 2


    ' Draw the icon and text
    e.Graphics.DrawImage(icon, New Rectangle(iconX, iconY, iconWidth, iconHeight))
    e.Graphics.DrawString("Edit", e.CellStyle.Font, Brushes.Black, New Point(textX, textY))
    e.Handled = True
    End If

تاپیک های مشابه

  1. سوال: انتقال یک پیام از کنترلر به ویو با کمک ویو دیتا یا ویو بق
    نوشته شده توسط kamran_14 در بخش ASP.NET MVC
    پاسخ: 3
    آخرین پست: چهارشنبه 12 اسفند 1394, 16:50 عصر
  2. پاسخ: 4
    آخرین پست: سه شنبه 13 مرداد 1394, 13:20 عصر
  3. پاسخ: 1
    آخرین پست: پنج شنبه 21 اسفند 1393, 19:19 عصر
  4. پاسخ: 3
    آخرین پست: پنج شنبه 15 آبان 1393, 18:27 عصر
  5. پاسخ: 2
    آخرین پست: چهارشنبه 02 اسفند 1391, 22:21 عصر

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •