Xtreme toolkit pro -- cxtpreportcontrol tutorial

Source: Internet
Author: User

The cxtpreportcontrol is a control in Xtreme toolkit pro. It is used to display tables. It can display the end of the table header, sort columns, Drag and Drop columns, and so on. It can also edit cells, very powerful. The following describes how to use it:

1. Add the following in the header file stdafx. h In the project:

# Include <xttoolkitpro. h> // Xtreme toolkit pro Component Library

2. If you want to use static connections, you should also:

Add the following line to your application's. RC2 file. This will link in the Toolkit resources so they are available to your application.

# Include <xttoolkitpro. rc>

For dynamic connection, copy the. dll of Xtreme toolkit to the output directory of exe.

3. Add the cxtpreportcontrol control:

(1) Add a custom control in the dialog box and change the class attribute of the control to xtpreport and the ID to idc_reportctrl_list.

(2) Add a custom variable: cxtpreportcontrol m_wndreportctrl;

(3) associate the control with the variable and add the following code in the oninitdialog () initialization function in the dialog box:

M_wndreportctrllist.subclassdlgitem (idc_reportctrl_list, this );

4. Set the display of the control:

// Initialize the appearance of the report

M_wndreportctrl.allowedit (false );

// M_wndreportctrl.editonclick (false );

// M_wndreportctrl.enabledragdrop (null, xtpreportallowdrag | xtpreportallowdrop); // you can drag a row.

M_wndreportctrl.enabletooltips (true); // A tooltips prompt is displayed in the column header.

// M_wndreportctrl.showheader (true); // display the header (displayed by default)

// M_wndreportctrl.showheaderrows (true); // display the header row

// M_wndreportctrl.showfooter (true); // display the footer, that is, under the interface, corresponding to the header

// M_wndreportctrl.showfooterrows (true); // display the footer row

// M_wndreportctrl.headerrowsallowedit (true); // You can edit headerrows.

// M_wndreportctrl.footerrowsallowedit (true); // You can edit footerrows.

// Colorref clrnew;

// Clrnew = RGB (0,255, 0 );

// M_wndreportctrl.setgridcolor (clrnew); // you can specify the gridline color.

M_wndreportctrl.setgridstyle (true, xtpreportgridstyle (xtpreportgridsolid); // set the vertical gridline Style

M_wndreportctrl.setgridstyle (false, xtpreportgridstyle (xtpreportgridsolid); // set the vertical gridline Style

// M_wndreportctrl.setfreezecolumnscount (2); // the two columns on the left are frozen. Note that this method must be used after the column is added.

M_wndreportctrl.getpaintmanager ()-> setcolumnstyle (xtpreportcolumnstyle (xtpreportcolumnoffice2007); // you can specify the column style.

// M_wndreportctrl.getpaintmanager ()-> setgridcolor (clrnew); // set the gridline color

M_wndreportctrl.getreportheader ()-> allowcolumnremove (false); // Columns cannot be removed.

M_wndreportctrl.getreportheader ()-> allowcolumnresize (true); // you can change the column width.

M_wndreportctrl.getreportheader ()-> allowcolumnsort (true); // you can sort all rows in a column.

M_wndreportctrl.getreportheader ()-> allowcolumnreorder (false); // re-sorting between columns is not allowed (by dragging the column header)

M_wndreportctrl.getreportheader ()-> setautocolumnsizing (true); // The width of each column cannot be adjusted automatically.

// Set the column width to false automatically. In this way, the column width does not change automatically as the reportcontrol width changes.

// If the sum of all column widths is greater than the reportcontrol width, the horizontal toolbar is automatically displayed.

M_wndreportctrl.setfullcolumnscrolling (false); // scroll horizontally by Pixel instead of column by column (that is, move a column after a scroll)

// M_wndreportctrl.setfullcolumnscrolling (true); // scroll one column by one (that is, move one column after one scroll)

M_wndreportctrl.setmultipleselection (true); // multiple selections are allowed.

5. add columns:

/// Add a column

Cxtpreportcolumn * pcol1 = new cxtpreportcolumn (0, _ T ("Serial Number"), 80 );

Pcol1-> setheaderalignment (dt_center );

Pcol1-> setalignment (dt_center );

// Pcol1-> seteditable (false); // It cannot be edited.

M_wndreportctrl.addcolumn (pcol1 );

6. Add rows

Cxtpreportrecord * precord = new cxtpreportrecord ();

Precord-> additem (New cxtpreportrecorditemnumber (I + 1); // row number

Precord-> additem (New cxtpreportrecorditemtext (m_p;roup-> m_arrdatatable [I]. m_sbusinfo); // Basic Information

Precord-> additem (New cxtpreportrecorditemnumber (m_p;roup-> m_arrdatatable [I]. m_dmw1, key_format_number ));

Precord-> additem (New cxtpreportrecorditemnumber (m_p;roup-> m_arrdatatable [I]. m_dmw2, key_format_number ));

Precord-> additem (New cxtpreportrecorditemnumber (m_p;roup-> m_arrdatatable [I]. m_dMw2-m_pDataGroup-> m_arrdatatable [I]. m_dmw1, key_format_number ));

M_wndreportctrl.addrecord (precord );

7. Display

M_wndreportctrl.populate ();

8. Add a report row focus change event:

(1) Add the message ing function to the header file of the Report Dialog Box:

Afx_msg void onreportfocuschanging (nmhdr * pnmhdr, lresult * result );

(2) In the source file of the Report Dialog Box, associate the message ing function with the report control, that is, add the following between begin_message_map and end_message_map:

On_notify (xtp_nm_report_focus_changing, idc_reportctrl_list, onreportfocuschanging)

(3) Implement the message ing function as follows:

// Events when the focus row in the table changes (including clicking with the mouse and using the keyboard's direction key)

Void cwereportdlg: onreportfocuschanging (nmhdr * pnotifystruct, lresult */* result */)

{

Xtp_nm_reportrecorditem * pitemnotify = (xtp_nm_reportrecorditem *) ppolicystruct;

If (! Pitemnotify) return;

Cxtpreportrow * prowsel = pitemnotify-> prow;

If (! Prowsel) return;

Trace (_ T ("click on row % d \ n"), prowsel-> getindex ());

Cxtpreportrecord * precordsel = prowsel-> getrecord ();

If (! Precordsel) return;

Cxtpreportrecorditemtext * ptext = (cxtpreportrecorditemtext *) (precordsel-> getitem (0 ));

If (! Ptext) return;

If (ptext-> getvalue (). Trim () = m_stablenamenow)

{

Return; // If the row to be clicked is the same as the previous row, the following operation is not required.

}

// Update the current record and ATC

M_stablenamenow = ptext-> getvalue (). Trim ();

If (m_stablenamenow! = "")

{

Findtablebyname (m_stablenamenow );

// After changing the selected report, update the selected and to-be-selected content.

Updatereporttable ();

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.