Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 550
  • Last Modified:

Updating a drivecombobox

I'm using a drivecombobox on a form and would like to be able to update it by pressing a button.

When I say update, I mean that I mapped to a network drive while the program is already running, and would like my application to detect this new drive without me having to close and reopen the application.

If there is a way to detect the change and update without even having to associate it to a button... even better.

Thanks in advance
0
rafy
Asked:
rafy
1 Solution
 
viktornetCommented:
Try this:
Maybe in OnTimer()....or you think of something...

DriveComboBox1.Update;//Updates and if there are new drives it will detect it hopefully...

Viktor Ivanov
0
 
rafyAuthor Commented:
Nope update doesn't do it... it only repaints the object...
0
 
westy100697Commented:
Hey Rafy try  DlgDirListComboBox() in Win32 and see if that helps. You will have to look at the command yourself but it has the ability to add all the current Drives, Directories etc.

You may have to call  CB_RESETCONTENT to clear the drive box first and reset it and then use the first procedure I mentioned. See if it helps...

WESTY :)
0
 
rafyAuthor Commented:
No... too messy...

I already found a much better solution... delete and recreate the object....Works for me.

Consider this question deleted (I'd delete it but I don't see that option).
0
 
itamarCommented:
Hi rafy,

this is the source code for a component that brings a reload method you can call from a Timer event:

>>>>>

type
  TNewDriveComboBox = class(TDriveComboBox)
  private
  protected
  public
     procedure Reload; virtual;
  published
  end;

procedure Register;

implementation

procedure TNewDriveComboBox.ReLoad;
begin
  inherited BuildList;
end;

procedure Register;
begin
  RegisterComponents('Samples', [TNewDriveComboBox]);
end;
<<<<<<

IHTH,
Itamar
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now