Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void populateList()
- {
- this->storageList = gcnew Generic::List<String ^>;
- storageList->Add("January");
- storageList->Add("February");
- storageList->Add("March");
- storageList->Add("April");
- storageList->Add("May");
- storageList->Add("June");
- storageList->Add("July");
- storageList->Add("August");
- storageList->Add("September");
- storageList->Add("October");
- storageList->Add("November");
- storageList->Add("December");
- }
- void handleTextChange()
- {
- String ^ searchText = toolStripComboBox->Text;
- toolStripComboBox->Items->Clear();
- Cursor->Current = Cursors::Default;
- if(searchText != "")
- {
- toolStripComboBox->DroppedDown = true;
- Regex ^ searchRegex = gcnew Regex("(?i).*"+searchText+".*");
- for(int i = 0; i<storageList->Count; i++)
- {
- Match ^ m = searchRegex->Match(storageList[i]);
- if(m->Success)
- {
- toolStripComboBox->Items->Add(storageList[i]);
- }
- }
- if(toolStripComboBox->Items->Count > 0)
- {
- String ^ sText = toolStripComboBox->Items[0]->ToString();
- toolStripComboBox->SelectionStart = searchText->Length;
- toolStripComboBox->SelectionLength = sText->Length - searchText->Length;
- }
- else
- {
- toolStripComboBox->DroppedDown = false;
- toolStripComboBox->SelectionStart = searchText->Length;
- }
- }
- else
- {
- toolStripComboBox->DroppedDown = false;
- toolStripComboBox->Items->Clear();
- }
- }
- toolStripComboBox_TextUpdate
- toolStripComboBox_KeyDown
- toolStripComboBox_DropDown
- toolStripComboBox_ChangeCommit
- toolStripComboBox_TextUpdate(System::Object^ sender, System::EventArgs^ e) {
- String ^ searchText = toolStripComboBox->Text;
- toolStripComboBox->Items->Clear();
- if(searchText != "") {
- Regex ^ searchRegex = gcnew Regex("(?i).*"+searchText+".*");
- for(int i = 0; i<storageList->Count; i++) {
- Match ^ m = searchRegex->Match(storageList[i]);
- if(m->Value == storageList[i]) {
- toolStripComboBox->Items->Add(storageList[i]);
- }
- }
- if(toolStripComboBox->Items->Count > 0) {
- toolStripComboBox->DroppedDown = true;
- toolStripComboBox->Text = searchText;
- Cursor->Current = Cursors::Default;
- }
- else {
- toolStripComboBox->DroppedDown = false;
- }
- toolStripComboBox->SelectionStart = searchText->Length;
- }
- else {
- toolStripComboBox->DroppedDown = false;
- toolStripComboBox->Items->Clear();
- }
- }
- toolStripComboBox_KeyDown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e) {
- String ^ searchText = toolStripComboBox->Text;
- if(e->KeyCode == Keys::Down || e->KeyCode == Keys::Up) {
- if(e->KeyCode == Keys::Down) {
- if(toolStripComboBox->SelectedIndex == -1 && toolStripComboBox->Items->Count > 0) {
- toolStripComboBox->SelectedIndex = 0;
- }
- }
- if(e->KeyCode == Keys::Up) {
- if(toolStripComboBox->SelectedIndex == -1 && toolStripComboBox->Items->Count > 0) {
- toolStripComboBox->SelectedIndex = toolStripComboBox->Items->Count - 1;
- }
- }
- keydownTxt->Text = Convert::ToString(toolStripComboBox->SelectedIndex);
- }
- if(e->KeyCode == Keys::Back) {
- toolStripComboBox->SelectionStart = searchText->Length;
- }
- if(e->KeyCode == Keys::Enter) {
- toolStripComboBox_ChangeCommit(sender, e);
- }
- }
- toolStripComboBox_DropDown(System::Object^ sender, System::EventArgs^ e) {
- String ^ searchText = toolStripComboBox->Text;
- toolStripComboBox->SelectionStart = searchText->Length;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement