| |

VerySource

 Forgot password?
 Register
Search
View: 1340|Reply: 11

Column width setting of DataGrid control in VC.NET !!

[Copy link]

1

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-23 01:00:01
| Show all posts |Read mode
I found a lot of information, and the methods in it are all 6.0
_variant_t vIndex;
 vIndex = long (0);
 m_datagrid.GetColumns (). GetItem (vIndex) .SetWidth (0);
It doesn't work at all. In 2015, the CDataGrid class does not have GetColumns (), GetItem (), SetWidth (), these functions. Some are LPDISPATCH get_Columns (); and void put_DefColWidth (float mewValue);
Help me, what are you going to do with column width !!!!!!!!
Reply

Use magic Report

0

Threads

21

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 United States

Post time: 2020-7-6 20:15:01
| Show all posts
m_datagrid.GetColumns() returns an LPDISPATCH. This LPDISPATCH should have a method called GetItem, and the return type is also LPDISPATCH. The LPDISPATCH returned by this GetItem should have a method called SetWidth.
But when you generate CDataGrid yourself, you should also generate these LPDISPATCH wrapper classes, just like you generate CDataGrid classes.
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-7-13 11:30:01
| Show all posts
After DataGrid is bound to a DataView, the collection of DataGridTableStyle objects in DataGrid.TableStyles controls which columns of this DataView are to be displayed, how wide the columns are, what the column header text is, and so on. Indeed, the DataGrid.TableStyles does not contain any objects. At this time, the DataGrid will display all the columns in the order of the DataView columns. In general applications, TableStyles will be set to control the displayed content and format.

Create a new TableStyle and correspond this TableStyle.MappingName property to the name of the DataTable to be controlled by this TableStyle:
DataGridTableStyle myTableStyle = new DataGridTableStyle();
myTableStyle.MappingName = "myDateTable";

Create a few more DataGridColumnStyle, which are used to control the several columns to be displayed
Add these DataGridColumnStyle to TableStyle
Finally add TableStyle to DataGrid
After adding TableStyle to DataGrid, then bind the data source
Reply

Use magic Report

1

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-16 15:00:01
| Show all posts
会飞啊() Reputation: 100
After the DataGrid is bound to a DataView, the collection of DataGridTableStyle objects in DataGrid.TableStyles controls which columns of the DataView are to be displayed, how wide the columns are, what the column header text is, and so on. Indeed, the DataGrid.TableStyles does not contain any objects. At this time, the DataGrid will display all the columns in the order of the DataView columns. In general applications, TableStyles will be set to control the displayed content and format.
-------------------------------------------------- -------------

Upstairs, I don't quite understand what you mean. I can't find the TableStyles and DataGridTableSytle objects you said in the DataGrid class, but thank you anyway.
On the second floor, there are no such functions as you mentioned in .NET.
Reply

Use magic Report

1

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-16 15:30:01
| Show all posts
Maybe I didn't make it clear that using the DataGrid control, only the CDataGrid class is automatically generated, there is no other class
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Unknown

Post time: 2020-7-17 00:30:01
| Show all posts
// dataGrid1
//
this->dataGrid1->AlternatingBackColor = System::Drawing::SystemColors::InactiveCaption;
this->dataGrid1->Anchor = (System::Windows::Forms::AnchorStyles)(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom )
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right);
this->dataGrid1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
this->dataGrid1->DataMember = S"";
this->dataGrid1->HeaderForeColor = System::Drawing::SystemColors::ControlText;
this->dataGrid1->ImeMode = System::Windows::Forms::ImeMode::NoControl;
this->dataGrid1->Location = System::Drawing::Point(10, 7);
this->dataGrid1->Name = S"dataGrid1";
this->dataGrid1->ReadOnly = true;
this->dataGrid1->RightToLeft = System::Windows::Forms::RightToLeft::No;
this->dataGrid1->Size = System::Drawing::Size(464, 456);
this->dataGrid1->TabIndex = 24;
System::Windows::Forms::DataGridTableStyle* __mcTemp__1[] = new System::Windows::Forms::DataGridTableStyle*[1];
__mcTemp__1[0] = this->dataGridTableStyle1;
this->dataGrid1->TableStyles->AddRange(__mcTemp__1);
this->dataGrid1->CurrentCellChanged += new System::EventHandler(this, on_selcell);
//
// dataGridTableStyle1
//
this->dataGridTableStyle1->AlternatingBackColor = System::Drawing::Color::DarkKhaki;
this->dataGridTableStyle1->DataGrid = this->dataGrid1;
System::Windows::Forms::DataGridColumnStyle* __mcTemp__2[] = new System::Windows::Forms::DataGridColumnStyle*[6];
__mcTemp__2[0] = this->dataGridTextBoxColumn1;
__mcTemp__2[1] = this->dataGridTextBoxColumn2;
__mcTemp__2[2] = this->dataGridTextBoxColumn3;
__mcTemp__2[3] = this->dataGridTextBoxColumn4;
__mcTemp__2[4] = this->dataGridTextBoxColumn5;
__mcTemp__2[5] = this->dataGridTextBoxColumn6;
this->dataGridTableStyle1->GridColumnStyles->AddRange(__mcTemp__2);
this->dataGridTableStyle1->HeaderForeColor = System::Drawing::SystemColors::ControlText;
this->dataGridTableStyle1->MappingName = S"table1";
this->dataGridTableStyle1->ReadOnly = true;
//
// dataGridTextBoxColumn1
//
this->dataGridTextBoxColumn1->Alignment = System::Windows::Forms::HorizontalAlignment::Right;
this->dataGridTextBoxColumn1->Format = S"";
this->dataGridTextBoxColumn1->FormatInfo = 0;
this->dataGridTextBoxColumn1->HeaderText = S "Course ID";
this->dataGridTextBoxColumn1->MappingName = S"courseno";
this->dataGridTextBoxColumn1->ReadOnly = true;
this->dataGridTextBoxColumn1->Width = 75;
//
// dataGridTextBoxColumn2
//
this->dataGridTextBoxColumn2->Alignment = System::Windows::Forms::HorizontalAlignment::Center;
this->dataGridTextBoxColumn2->Format = S"";
this->dataGridTextBoxColumn2->FormatInfo = 0;
this->dataGridTextBoxColumn2->HeaderText = S "Course Name";
this->dataGridTextBoxColumn2->MappingName = S"coursename";
this->dataGridTextBoxColumn2->ReadOnly = true;
this->dataGridTextBoxColumn2->Width = 150;
//
// dataGridTextBoxColumn3
//
this->dataGridTextBoxColumn3->Alignment = System::Windows::Forms::HorizontalAlignment::Center;
this->dataGridTextBoxColumn3->Format = S"";
this->dataGridTextBoxColumn3->FormatInfo = 0;
this->dataGridTextBoxColumn3->HeaderText = S "Course Type";
this->dataGridTextBoxColumn3->MappingName = S"coursetype";
this->dataGridTextBoxColumn3->ReadOnly = true;
this->dataGridTextBoxColumn3->Width = 75;
//
// dataGridTextBoxColumn4
//
this->dataGridTextBoxColumn4->Alignment = System::Windows::Forms::HorizontalAlignment::Center;
this->dataGridTextBoxColumn4->Format = S"";
this->dataGridTextBoxColumn4->FormatInfo = 0;
this->dataGridTextBoxColumn4->HeaderText = S "Starting semester";
this->dataGridTextBoxColumn4->MappingName = S"openterm";
this->dataGridTextBoxColumn4->ReadOnly = true;
this->dataGridTextBoxColumn4->Width = 75;
//
// dataGridTextBoxColumn5
//
this->dataGridTextBoxColumn5->Alignment = System::Windows::Forms::HorizontalAlignment::Center;
this->dataGridTextBoxColumn5->Format = S"";
this->dataGridTextBoxColumn5->FormatInfo = 0;
this->dataGridTextBoxColumn5->HeaderText = S "Number of Class Hours";
this->dataGridTextBoxColumn5->MappingName = S"coursehours";
this->dataGridTextBoxColumn5->ReadOnly = true;
this->dataGridTextBoxColumn5->Width = 50;
//
// dataGridTextBoxColumn6
//
this->dataGridTextBoxColumn6->Alignment = System::Windows::Forms::HorizontalAlignment::Center;
this->dataGridTextBoxColumn6->Format = S"";
this->dataGridTextBoxColumn6->FormatInfo = 0;
this->dataGridTextBoxColumn6->HeaderText = S "credits";
this->dataGridTextBoxColumn6->MappingName = S"credit";
this->dataGridTextBoxColumn6->ReadOnly = true;
this->dataGridTextBoxColumn6->Width = 50;
Reply

Use magic Report

1

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-17 19:30:01
| Show all posts
Sorry for misunderstanding会飞啊.
The DataGrid that I said is the ActireX control, it is the ActireX control of VB6.0
DataGrid that is not a .NET Framework component
Sorry for the inconvenience
Does anyone know how to deal with such problems, thank you
Reply

Use magic Report

0

Threads

21

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 United States

Post time: 2020-7-18 11:15:01
| Show all posts
You can generate MFC classes from the built-in type library of OCX
http://support.microsoft.com/kb/140616
Reply

Use magic Report

1

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-8-8 08:30:01
| Show all posts
I went to find a class automatically generated by VC to solve the problem.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-6 22:00:01
| Show all posts
Did the host solve the problem?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list