Click here to Skip to main content
15,914,488 members
Home / Discussions / C#
   

C#

 
AnswerI have found the answer Pin
lune1216-Sep-08 2:09
lune1216-Sep-08 2:09 
GeneralRe: I have found the answer Pin
dojohansen16-Sep-08 2:29
dojohansen16-Sep-08 2:29 
GeneralRe: I have found the answer Pin
lune1216-Sep-08 2:57
lune1216-Sep-08 2:57 
AnswerRe: check if file exists with wild char in file name Pin
teejayem16-Sep-08 2:45
teejayem16-Sep-08 2:45 
GeneralRe: check if file exists with wild char in file name Pin
lune1216-Sep-08 2:58
lune1216-Sep-08 2:58 
QuestionDatagridview & Email Pin
Chrispie12316-Sep-08 1:27
Chrispie12316-Sep-08 1:27 
GeneralRe: Datagridview & Email Pin
nelsonpaixao16-Sep-08 14:18
nelsonpaixao16-Sep-08 14:18 
QuestionDesign-time databound property Pin
Besoc16-Sep-08 0:51
Besoc16-Sep-08 0:51 
Hello

I'm trying to extend a standard Windows Forms ComboBox, by adding a new property ImageMember which should display an image from database. It is supposed to be the databound property just like DisplayMember and ValueMember are.

At run-time everything works correctly. My question is how to allow one to choose a field from dataset for this property at design-time, just like you do for DisplayMember property.

The short question is: How can I make ImageMember property editor behave as DisplayMember's at design-time?

I've looked through internet and the closest solution seems to be the following:

public class ImageMemberEditor: UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if (context != null) 
                return UITypeEditorEditStyle.DropDown;
            return base.GetEditStyle(context);
        }


        public override object EditValue(ITypeDescriptorContext context,IServiceProvider provider,object value)
        {
            if ((provider != null) && (context.Instance != null))
            {
                PropertyDescriptor descriptor = TypeDescriptor.GetProperties(context.Instance)["DataSource"];
                if (descriptor == null)
                {
                    return value;
                }
                
                object dataSource = descriptor.GetValue(context.Instance);
                if (this.DesignBindingPicker == null)
                {
                    this.designBindingPicker = new DesignBindingPicker();
                }
                DesignBinding initialSelectedItem = new DesignBinding(dataSource, (string)value);
                DesignBinding binding2 = this.designBindingPicker.Pick(context, provider, false, true, true, dataSource, string.Empty, initialSelectedItem);
                if ((dataSource != null) && (binding2 != null))
                {
                    value = binding2.DataMember;
                }
                value = lb.SelectedItem.ToString();// (dataSource as System.Windows.Forms.BindingSource).CurrencyManager.Current.ToString();
              }
            
            return value;
        }
    }


However, Visual Studio can not resolve designBindingPicker and DesignBinding :

"Error 5 The type or namespace name 'DesignBinding' could not be found (are you missing a using directive or an assembly reference?)"


Any help will be greately appreciated.

Thanks in advance
AnswerRe: Design-time databound property Pin
dojohansen16-Sep-08 2:49
dojohansen16-Sep-08 2:49 
GeneralRe: Design-time databound property Pin
Besoc16-Sep-08 4:15
Besoc16-Sep-08 4:15 
QuestionSelect Column Names Pin
omlac16-Sep-08 0:34
omlac16-Sep-08 0:34 
AnswerRe: Select Column Names Pin
dojohansen16-Sep-08 2:41
dojohansen16-Sep-08 2:41 
QuestionSound Device Properties Pin
jam198216-Sep-08 0:19
jam198216-Sep-08 0:19 
QuestionRegarding Sharepoint Text message Pin
manju#12316-Sep-08 0:13
manju#12316-Sep-08 0:13 
QuestionMemory usage problem Pin
stancrm15-Sep-08 22:59
stancrm15-Sep-08 22:59 
AnswerRe: Memory usage problem Pin
Harvey Saayman15-Sep-08 23:29
Harvey Saayman15-Sep-08 23:29 
GeneralRe: Memory usage problem Pin
Dave Kreskowiak16-Sep-08 2:02
mveDave Kreskowiak16-Sep-08 2:02 
AnswerRe: Memory usage problem Pin
DaveyM6915-Sep-08 23:44
professionalDaveyM6915-Sep-08 23:44 
AnswerRe: Memory usage problem Pin
Frank Horn16-Sep-08 0:12
Frank Horn16-Sep-08 0:12 
AnswerRe: Memory usage problem Pin
Dave Kreskowiak16-Sep-08 2:06
mveDave Kreskowiak16-Sep-08 2:06 
GeneralRe: Memory usage problem Pin
Dan Neely16-Sep-08 2:12
Dan Neely16-Sep-08 2:12 
QuestionWhy is like that ? [modified] Pin
Mogaambo15-Sep-08 22:35
Mogaambo15-Sep-08 22:35 
AnswerRe: Why is like that ? Pin
N a v a n e e t h15-Sep-08 22:45
N a v a n e e t h15-Sep-08 22:45 
GeneralRe: Why is like that ? Pin
Mogaambo15-Sep-08 23:02
Mogaambo15-Sep-08 23:02 
GeneralRe: Why is like that ? Pin
DaveyM6915-Sep-08 23:23
professionalDaveyM6915-Sep-08 23:23 

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.