Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , ,

Sponsored Links


Display form in VB based on user's choice

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 12-12-2009
ASHER's Avatar
Member
 
Join Date: Jun 2009
Posts: 87
Display form in VB based on user's choice

Sponsored Links
In fact I have several from which have the same layout and same features (display list and buttons to add, edit, delete), its just the data exchange. And I want (if possible) to form a single window and data will be filled according to the user's choice when he will click on a field in the menu. I'm already in PHP and is very practical, it avoids making the same transaction and it's faster if modified. I would like to do it on my VB project but I do not know how

Reply With Quote
  #2  
Old 12-12-2009
Member
 
Join Date: May 2008
Posts: 2,000
Re: Display form in VB based on user's choice

You can create your Form Generic. And when you call, depending on what the user click you do not load the same data. As you'll say that my answer makes sense (to logical question), I anticipate:

I guess:
- Your list will contain lines that come from your database.
- So you have to load your data into a dataset
- This dataset will be the source of your DataGrid that will display lines
- Depending on the call button, and well you use it the same query to populate the dataset.
- And for your functions Add, Edit, etc. well if you're making based on the case.
Reply With Quote
  #3  
Old 12-12-2009
Praetor's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,943
Re: Display form in VB based on user's choice

For the most part call and make a parametrized constructor; if the form differs value as an identifier you pass; if the function changes depending on the type of form you can use an enum

Examples for the 2 cases
Code:
public sub new (Id as long)
  initiliazecomponent
  ' treatment by id for managing display
end sub
or with an enum
Code:
public enum TypeOpen
  add = 1
  modify = 2
end enum
 
public sub new (open as TypeOpen)
  select case open 
    case add
       ' layout for the add
    case modify 
      ' layout for the modify 
  end select
end sub
Reply With Quote
  #4  
Old 12-12-2009
ASHER's Avatar
Member
 
Join Date: Jun 2009
Posts: 87
Re: Display form in VB based on user's choice

Quote:
- Your list will contain lines that come from your database.
Great
Quote:
- So you have to load your data into a dataset
- This dataset will be the source of your DataGrid that will display lines
I never used the DataSet (I'm beginner ), I use DataGridView (there was only that in the tutorial that I read ). What's the point if we can directly display with DataGrid?
Quote:
For the most part call and make a parametrized constructor; if the form differs value as an identifier you pass;
No, it does not change compared to the identifier. It is more compared to the table. I explain: I have a menu where you can choose between Ram, processor or motherboard. When the user clicks on one of the 3 it to a page with:
- Left: the list (eg processors)
- Right: 3 buttons (Add, Modify, Delete)
Quote:
if the function changes depending on the type of form you can use an enum
I did some research on ENUM for the first time, but I have not quite understood the functioning and usefulness?
Reply With Quote
  #5  
Old 12-12-2009
Praetor's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,943
Re: Display form in VB based on user's choice

Usefulness is to appoint an integer value, that avoids coding errors and that makes the code readable. Imagine your form or you have your requests in 3 variables
Code:
private _RqRam as string = "select * from ram"
private _RqProcessors as string = "select * from processors"
private _RqCms as string = "select * from cms"
you could very well filtered against a value
Code:
public sub new (typeopen as integer)
  select case typeopen 
     case 1
       mycmd.commandtext = _rqram
     case 2
       mycmd.commandtext = _rqprocessors
     case 3
       mycmd.commandtext = _rqcms
   end select
    ' execution of the application and filling datagrid
end sub
So you can arbitrarily say that if you want to display it sends 1 ram etc. So on another form that calls it that you would
Code:
dim f as new frmdisplayPieces(1)
f.show
usefulness of the enum is therefore as I said to improve readability
Code:
public enum TypeOpen as integer
  ram = 1
  processors = 2
  cms = 3
end enum
 
public sub new (typeopen as TypeOpen)
  select case typeopen 
     case ram
       mycmd.commandtext = _rqram
     case processors 
       mycmd.commandtext = _rqprocessors
     case cms
       mycmd.commandtext = _rqcms
   end select
    ' execution of the application and filling datagrid
end sub
and
Code:
dim f as new frmdisplayPieces(ram)
f.show
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Display form in VB based on user's choice"
Thread Thread Starter Forum Replies Last Post
Create a user control form in Excel 2010 --MasseySian-- Software Development 3 06-09-2012 07:03 PM
Need help to create a login user form in Microsoft Excel Henriksen MS Office Support 2 23-02-2012 05:04 PM
Drupal : Add new fields in the form of user / register Arrosa Software Development 6 05-01-2011 04:11 AM
Unable to display value in asp.net form Juaquine Software Development 4 01-02-2010 08:12 PM
Thunderbird : display of attachments in list form Beter 2 Burn Out Technology & Internet 4 30-03-2009 03:40 PM


All times are GMT +5.5. The time now is 05:25 AM.