Click here to Skip to main content
15,887,585 members
Home / Discussions / C#
   

C#

 
AnswerRe: Disable combo box on selecting an option. Pin
BillWoodruff9-Feb-14 6:18
professionalBillWoodruff9-Feb-14 6:18 
Questionvideo and gps Pin
jas168-Feb-14 23:21
jas168-Feb-14 23:21 
AnswerRe: video and gps Pin
Ravi Bhavnani9-Feb-14 4:34
professionalRavi Bhavnani9-Feb-14 4:34 
QuestionGetting Data From User Pin
RebornProgrammer8-Feb-14 21:00
RebornProgrammer8-Feb-14 21:00 
AnswerRe: Getting Data From User Pin
OriginalGriff8-Feb-14 23:21
mveOriginalGriff8-Feb-14 23:21 
QuestionWrite to notepad or other windows Pin
alirezamansoori8-Feb-14 19:27
alirezamansoori8-Feb-14 19:27 
AnswerRe: Write to notepad or other windows Pin
OriginalGriff8-Feb-14 19:58
mveOriginalGriff8-Feb-14 19:58 
QuestionHow to Fetch UserName & Current Date automatically. Pin
Mohan Subramani8-Feb-14 7:01
Mohan Subramani8-Feb-14 7:01 
AnswerRe: How to Fetch UserName & Current Date automatically. Pin
OriginalGriff8-Feb-14 7:32
mveOriginalGriff8-Feb-14 7:32 
AnswerRe: How to Fetch UserName & Current Date automatically. Pin
Dave Kreskowiak8-Feb-14 9:22
mveDave Kreskowiak8-Feb-14 9:22 
AnswerRe: How to Fetch UserName & Current Date automatically. Pin
Mycroft Holmes8-Feb-14 13:35
professionalMycroft Holmes8-Feb-14 13:35 
AnswerRe: How to Fetch UserName & Current Date automatically. Pin
Richard Deeming10-Feb-14 1:37
mveRichard Deeming10-Feb-14 1:37 
Questionhow can i get min value in datatable with distinct items using loops Pin
yahiaalaa8-Feb-14 5:49
yahiaalaa8-Feb-14 5:49 
AnswerRe: how can i get min value in datatable with distinct items using loops Pin
TnTinMn8-Feb-14 6:54
TnTinMn8-Feb-14 6:54 
AnswerRe: how can i get min value in datatable with distinct items using loops Pin
Mycroft Holmes8-Feb-14 13:31
professionalMycroft Holmes8-Feb-14 13:31 
AnswerRe: how can i get min value in datatable with distinct items using loops Pin
Md Nazmoon Noor13-May-14 3:21
Md Nazmoon Noor13-May-14 3:21 
QuestionSSH Connection to Cisco Router Pin
sikas_Cisco8-Feb-14 4:36
sikas_Cisco8-Feb-14 4:36 
SuggestionRe: SSH Connection to Cisco Router Pin
Richard MacCutchan8-Feb-14 5:28
mveRichard MacCutchan8-Feb-14 5:28 
GeneralRe: SSH Connection to Cisco Router Pin
sikas_Cisco8-Feb-14 5:34
sikas_Cisco8-Feb-14 5:34 
GeneralRe: SSH Connection to Cisco Router Pin
Richard MacCutchan8-Feb-14 5:37
mveRichard MacCutchan8-Feb-14 5:37 
GeneralRe: SSH Connection to Cisco Router Pin
dharmegh9-Feb-14 19:23
dharmegh9-Feb-14 19:23 
QuestionAttributes Help: Defining an item list in an attribute Pin
helkhoury7-Feb-14 20:29
helkhoury7-Feb-14 20:29 
I am writing a program which will connect to a I2C to USB controller. I am using WPF.
I decided to create a Device class to contain the hardware description and all its attributes so I can use them to display properties and have the end user modify the settings of the hardware.
I have most of the above working, except 2 attributes.
Most attributes are strings or int or byte, etc... so they are easy to work with, like the example below:
C#
private string _name;
       [Category("General")]
       [ReadOnly(false)]
       [DisplayName("Module Name")]
       [Description("Enter descriptive string ")]
       public string Name { get { return _name; } set { _name = value; OnPropertyChanged("Module Name"); } }


The 2 attributes I am having a hard time with need to have a list to populate.
So I read the hardware setting, and it returns that it supports I2C, SPI, and UART.
Now I want to be able to pass those to the "CommunicationType" attribute, and have it display as a list in the properties window.
To see if my program is working, I created the following class:
C#
public class CommunicationType : IItemsSource
{
    public ItemCollection GetValues()
    {
        ItemCollection sizes = new ItemCollection();
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.I2C, "I2C");
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.ISSP, "ISSP");
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.JTAG, "JTAG");
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.SPI, "SPI");
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.SWD, "SWD");
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.SWD_SWV, "SWD SWV");
        return sizes;
    }
}

Then in the attribute, I have the following:
C#
private int _comtype;
       [Category("Settings")]
       [ReadOnly(false)]
       [ItemsSource(typeof(CommunicationType))]
       [DisplayName("Communication Type")]
       public int CommunicationType { get { return _comtype; } set { _comtype = value; OnPropertyChanged("Communication Type"); } }


So when I run it, it gives the user the possibility to select from a drop down, one of the communication types.
Now the question is, how do I populate it programmatically. Some of the hardware only supports I2C and SPI, so I only want to populate the list with 2 items based on the hardware.

Any guidance or examples are greatly appreciated.
Thanks,
H-

modified 8-Feb-14 2:56am.

QuestionUsing of Abstract class and Interface class Pin
Rupaswathi7-Feb-14 19:06
Rupaswathi7-Feb-14 19:06 
AnswerRe: Using of Abstract class and Interface class Pin
Richard MacCutchan7-Feb-14 22:10
mveRichard MacCutchan7-Feb-14 22:10 
QuestionC# dll import Pin
Member 42110407-Feb-14 5:40
Member 42110407-Feb-14 5:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.