Windows Develop Bookmark and Share   
 index > Windows Forms Designer > How to create new property (cols,Rows) to DataGridView
 

How to create new property (cols,Rows) to DataGridView

Hi All !

I want create new property ( Rows , Cols) to DataGridView
(->So I can choice and set Rows munber and cols munber from form design)
Please tell me what I have todo ?
Thanks All support.


Le Minh Hai  Friday, July 25, 2008 5:01 AM

Hi Le Minh Hai

I have an example to share with you which can help you to implement this effect.

Code Snippet

publicclass M_DataGridView : System.Windows.Forms.DataGridView

{

private Point _rowsColumns; // The custom property of your DataGridView

public M_DataGridView()

{

_rowsColumns = new Point();

}

public Point RowsColumns

{

get

{

return _rowsColumns;

}

set

{

_rowsColumns = value;

}

}

Then you can get the values you have set by the code below:

Code Snippet

dgvRowsCount = this.m_DataGridView1.RowsColumns.X;

dgvColumnsCount = this.m_DataGridView1.RowsColumns.Y;

Wish you can solve your problem soon.

Best Regards,

Kira Qian

Windows Forms General FAQs
Windows Forms Data Controls and Databinding FAQs

Kira Qian  Tuesday, July 29, 2008 8:48 AM

Hi Le Minh Hai

I have an example to share with you which can help you to implement this effect.

Code Snippet

publicclass M_DataGridView : System.Windows.Forms.DataGridView

{

private Point _rowsColumns; // The custom property of your DataGridView

public M_DataGridView()

{

_rowsColumns = new Point();

}

public Point RowsColumns

{

get

{

return _rowsColumns;

}

set

{

_rowsColumns = value;

}

}

Then you can get the values you have set by the code below:

Code Snippet

dgvRowsCount = this.m_DataGridView1.RowsColumns.X;

dgvColumnsCount = this.m_DataGridView1.RowsColumns.Y;

Wish you can solve your problem soon.

Best Regards,

Kira Qian

Windows Forms General FAQs
Windows Forms Data Controls and Databinding FAQs

Kira Qian  Tuesday, July 29, 2008 8:48 AM
Hi Kira Qian - MSFT
Thanks your code you gave me, It really helpful
Best regards,
Thanks all support!
Le Minh Hai  Wednesday, July 30, 2008 11:23 PM

You can use google to search for other answers

Custom Search

More Threads

• Creating Panels when Items are Added in CollectionBase at Designtime
• How to create a Custom Form that appears in the Toolbox and is droppable on the Design Surface?
• CanConvertTo Not Called
• Extending Treeview
• Problem with Windows Forms Designer...
• Designer Form Error - Service Type
• BehaviorService Errors / Questions
• Tracking text entry position
• design mode and copy & paste
• DataGridView - Edit columns after changing Dataset