Datagridview Custom Control (VB.Net)

Answered
0
0

I have been trying to convert the c# code in the link below (customer control in datagridview column) but i am getting errors. Can you pls assist me with the correct way of achieving that

https://docs.wisej.com/docs/controls/lists/datagridview

C# Code

this.dataGridView1.Rows[0][2].Control = new TrackBar

{

Value = 10,

Dock = DockStyle.Fill

};

 

VB.Net Code

dataGridView1.Rows(0)(3).Control = New ProgressBar (Value = 10, Dock = DockStyle.Fill)

dataGridView1.Rows(0)(3).Control = New ProgressBar {Value = 10, Dock = DockStyle.Fill}

  • You must to post comments
Best Answer
1
0

Hi Nicholas,

I just wanted to also point out that with this here you’re going to create a Control for each individual cell.

if the grid has 1000 rows it creates a 1000 controls. if it’s just meant to display custom content in a grid cell then the answer in one of your previous posts (https://wisej.com/support/question/display-progrgress-percentage-in-datagridview-column) is the right thing to do.

Adding to that you don’t even have to change the value of the cell with HTML, but you can instead handle CellFormatting and format what is rendered in the cell without putting html in the cell value.
Let me know if you need anything!
Best,
Alaa

//

  • Nicholas
    Thanks Alaa for the quick response. Yes all i wanted to achieve was to display the column as a progress bar. I tried the solution in my earlier question but was having issues and that is why i was looking for an alternative. I played with the earlier sample after your suggestion and i have been able to achieve exactly what i need. Thanks so much for the suggestion.
  • You must to post comments
1
0

Hi Nicholas,

You can achieve your goal using :

'1
Dim progressBar As New ProgressBar
progressBar.Value = 10
progressBar.Dock = DockStyle.Fill

dataGridView1.Rows(0)(3).Control = prog

or

'2
dataGridView1.Rows(0)(3).Control = New ProgressBar With {.Value = 10, .Dock = DockStyle.Fill}

HTH,
Alaa

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.