Detecting A Modifier Key Is Pressed if (Control::ModifierKeys == Keys::Control) Detecting A Single Modifier Key Is Pressed if (Control::ModifierKeys & Keys::Shift) != 0)
All posts by
Detecting Key Presses On A Form
Select the form: Set the KeyPreview property of the form to true so that keyboard messages are received by the form before they reach any controls on the form. Create a KeyPress event (detects keys down combined with any modifier key – i.e. no event for pressing CTRL and a modified key value for CTRL […]
Chart Types
Line Charts Displaying Points Series > Marker Style
Title
Create a global title object private: DataVisualization::Charting::Title ^ChartTitle1; Set the title //Add the chart title if this is the first time if (ChartTitle1 == nullptr) { ChartTitle1 = gcnew DataVisualization::Charting::Title(); ChartTitle1->Name = L”Title1″; Chart1->Titles->Add(ChartTitle1); } ChartTitle1->Text = L”Test”; //Changing this at any time will update the charts title
Working With Fonts
Setting Font dataGridView1->DefaultCellStyle->Font = gcnew System::Drawing::Font(“Arial”, 10);
Printing General
Create Your Print Document System::Drawing::Printing::PrintDocument ^printDoc; Start Printing //Setup the print dialog PrintDialog ^dlgPrint = gcnew PrintDialog(); dlgPrint->AllowSelection = true; dlgPrint->ShowNetwork = true; dlgPrint->Document = printDoc; dlgPrint->PrinterSettings->DefaultPageSettings->Landscape = true; //(This doesn’t necessarily work) dlgPrint->UseEXDialog = true; printDoc->BeginPrint += gcnew System::Drawing::Printing::PrintEventHandler(this, &DataGridViewPrint::PrintDoc_BeginPrint); printDoc->PrintPage += gcnew System::Drawing::Printing::PrintPageEventHandler(this, &DataGridViewPrint::PrintDoc_PrintPage); if (dlgPrint->ShowDialog() != DialogResult::OK) { printDoc->BeginPrint -= gcnew System::Drawing::Printing::PrintEventHandler(this, […]
Page Settings
You can’t easily force things like margins and orientation, all you can do is use dlgPrint->PrinterSettings->DefaultPageSettings->Landscape = true; Which if not forced and often ignored leaving the user to have to decide. Detecting Page Orientation You can do this in the print page callback: void DataGridViewPrint::PrintDoc_PrintPage(System::Object ^sender, System::Drawing::Printing::PrintPageEventArgs ^e) { if (e->PageSettings->Landscape) //True for landscape
Print A Chart
You can go through a process of copying to clipboard, then printing, or you can just use: Chart1->Printing->Print(true);
Copy To Clipboard
Copy Data Grid View To Clipboard Copies as a spreadsheet so it pastes perfectly into Excel and Word //Set the ClipboardCopyMode property to define if column and row headers should be included dataGridView1->SelectAll(); //Select by individual cell method: //for (Row = 0; Row < dataGridView1->RowCount; Row++) //{ // for (Column = ; Column < dataGridView1->Columns->Count; […]
Copy to clipboard
Copy Chart To Clipbaord MemoryStream ^MemoryStream1 = gcnew MemoryStream(); Chart1->SaveImage(MemoryStream1, DataVisualization::Charting::ChartImageFormat::Bmp); System::Drawing::Bitmap ^Bitmap1 = gcnew System::Drawing::Bitmap(MemoryStream1); System::Windows::Forms::Clipboard::SetImage(Bitmap1);
