I have a ComboBox containing Unicode symbols, the font is set to a Unicode-Supporting font and it displays them just fine. But the DropDown section seems to use a standard font which cannot display these Unicode symbols. Is there a way to change this inside the properties or do I have to create a customized ComboBox control?
EDIT:
My Code:
public class MainWindow : Form {
...
public BindingList<Sound> Sounds { get; set; } = new BindingList<Sound>();
public MainWindow() {
InitializeComponent();
this.comboBox.DataSource = this.Sounds;
}
...
}
public class Sound {
public char Symbol { get; private set; }
public Sound(char symbol) {
this.Symbol = symbol;
}
public override int GetHashCode() {
return this.Symbol.GetHashCode();
}
public override bool Equals(object obj) {
if(obj is Sound) {
return this.Symbol == ((Sound)obj).Symbol;
}
return base.Equals(obj);
}
public override string ToString() {
return this.Symbol.ToString();
}
public void Play() {
...
}
}
Related
When we set the tab an icon and text, you can see the icon is horizontally aligned with tab text. But if you want to place the icon above the tab label, you have to use a custom view to achieve it.
Java
class ViewPagerAdapter extends FragmentPagerAdapter
{
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager)
{
super(manager);
}
#Override
public Fragment getItem(int position)
{
return mFragmentList.get(position);
}
#Override
public int getCount()
{
return mFragmentList.size();
}
public void addFrag(Fragment fragment, String title)
{
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
#Override
public CharSequence getPageTitle(int position)
{
return mFragmentTitleList.get(position);
}
}
Xamarin.Android
class ViewPagerAdapter : FragmentPagerAdapter
{
private List<Android.Support.V4.App.Fragment> mFragmentList = new List<Android.Support.V4.App.Fragment>();
private List<string> mFragmentTitleList = new List<string>();
public ViewPagerAdapter(Android.Support.V4.App.FragmentManager manager)
{
//base.OnCreate(manager);
}
public override int Count
{
get
{
return mFragmentList.Count;
}
}
public override Android.Support.V4.App.Fragment GetItem(int postion)
{
return mFragmentList[postion];
}
public CharSequence GetPageTitle(int position)
{
return mFragmentTitleList[position];
}
public void addFragment(Android.Support.V4.App.Fragment fragment, string title)
{
mFragmentList.Add(fragment);
mFragmentTitleList.Add(title);
}
}
What's that? when the super(manager) be covert to xamarin android.
CharSequence GetPageTitle. they got a error-> cannot be used as return type
class ViewPagerAdapter : FragmentPagerAdapter
{
private List<Android.Support.V4.App.Fragment> mFragmentList = new List<Android.Support.V4.App.Fragment>();
private List<string> mFragmentTitleList = new List<string>();
public ViewPagerAdapter(Android.Support.V4.App.FragmentManager manager)
: base(manager)
{
}
public override int Count
{
get
{
return mFragmentList.Count;
}
}
public override Android.Support.V4.App.Fragment GetItem(int postion)
{
return mFragmentList[postion];
}
public override ICharSequence GetPageTitleFormatted(int position)
{
return new Java.Lang.String(mFragmentTitleList[position]);
}
public void AddFragment(Android.Support.V4.App.Fragment fragment, string title)
{
mFragmentList.Add(fragment);
mFragmentTitleList.Add(title);
}
}
I am currently having an issue where I am trying to do a check in a workflow before saving the custom form content item as a submission. Once the CreateAndPublish workflow is hit, it actually creates the item, but the field values aren't being saved properly.
Here is my workflow:
public class CreateAndPublishActivity : Task {
private readonly IContentManager _contentManager;
public CreateAndPublishActivity(IContentManager contentManager) {
_contentManager = contentManager;
}
public Localizer T { get; set; }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) {
return true;
}
public override IEnumerable<LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) {
return new[] { T("Done") };
}
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) {
_contentManager.Create(workflowContext.Content.ContentItem, VersionOptions.Published);
yield return T("Done");
}
public override string Name {
get { return "CreateAndPublish"; }
}
public override LocalizedString Category {
get { return T("Content Items"); }
}
public override LocalizedString Description {
get { return T("Create and Publish the content item."); }
}
}
The content item shows up under submissions, but none of the field values are there.
I have ClassLibrary (in visual studio 2010 C#) with a class Car:
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("ClassLibrary1.Car")]
public class Car
{
public Car()
{
Name = "";
Parts = new List<string>();
}
public string Name { get; set; }
public List<string> Parts { get; set; }
}
But when I use it in vb6 project: there is no property "Parts":
http://i.imgur.com/x4h3BMp.jpg?1
What can I do to make property List<> visible?
Of course, the file "AssemblyInfo.cs" contains:
[assembly: ComVisible(true)]
P.S. I really do not want to create for each List the class, like this:
public class Parts
{
private List<string> _parts;
public Parts()
{
_parts = new List<string>();
}
public void Add(string part)
{
_parts.Add(part);
}
public string GetAt(int index)
{
if (0 <= index && index < _parts.Count)
return _parts[index];
return "";
}
public void Clear()
{
_parts.Clear();
}
public int Count{ get{ return _parts.Count; } }
}
because there are too many.
COM does not support generic collections; you'll have to use an array or ArrayList instead:
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("ClassLibrary1.Car")]
public class Car
{
public Car()
{
Name = "";
Parts = new string[];
}
public string Name { get; set; }
public string[] Parts { get; set; }
}
If you want to use a List behind-the-scenes you could use a List<string> as a backing variable, then change the property accessors to translate the list to/from an array:
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("ClassLibrary1.Car")]
public class Car
{
private List<string> _Parts;
public Car()
{
Name = "";
_Parts = new List<string>();
}
public string Name { get; set; }
public string[] Parts
{
get
{
return _Parts.ToArray();
}
set
{
_Parts = new List<string>(value);
}
}
}
I did not want to do so, but had:
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("ClassLibrary1.Car")]
public class Car
{
public Car()
{
Name = "";
Parts = new Parts();
}
public string Name { get; set; }
public Parts Parts { get; set; }
}
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("ClassLibrary1.Parts")]
public class Parts : IList<string>
{
private List<string> _parts;
public Parts()
{
_parts = new List<string>();
}
#region IList<string> Members
public int IndexOf(string item)
{
return _parts.IndexOf(item);
}
public void Insert(int index, string item)
{
_parts.Insert(index, item);
}
public void RemoveAt(int index)
{
_parts.RemoveAt(index);
}
public string this[int index]
{
get
{
return _parts[index];
}
set
{
_parts[index] = value;
}
}
#endregion
#region ICollection<string> Members
public void Add(string item)
{
_parts.Add(item);
}
public void Clear()
{
_parts.Clear();
}
public bool Contains(string item)
{
return _parts.Contains(item);
}
public void CopyTo(string[] array, int arrayIndex)
{
_parts.CopyTo(array, arrayIndex);
}
public int Count
{
get { return _parts.Count; }
}
public bool Remove(string item)
{
return _parts.Remove(item);
}
#endregion
#region ICollection<string> Members
public bool IsReadOnly
{
get { throw new NotImplementedException(); }
}
#endregion
#region IEnumerable<string> Members
public IEnumerator<string> GetEnumerator()
{
throw new NotImplementedException();
}
#endregion
#region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
#endregion
}
In vb6:
Option Explicit
Dim car As New ClassLibrary1.car
Dim parts As New ClassLibrary1.parts
Private Sub Form_Load()
parts.Add "wheel"
parts.Add "door"
parts.Add "hood"
parts.Add "trunk"
car.Name = "GAS-24"
Set car.parts = parts
car.parts.RemoveAt (0)
End Sub
Drawback of this approach is a lot of code:(
Let me know, if anyone knows something like this:
//**[MakeVisibleListInVB6]**
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("ClassLibrary1.Car")]
public class Car
{
public Car()
{
Name = "";
Parts = new Parts();
}
public string Name { get; set; }
public List<string> Parts { get; set; }
}
How to do something like this (without creating intermediate classes):
abstract class A
{
public abstract string Text { get; }
}
class B : A
{
string text = "";
public override string Text
{
get { return text; }
}
new public string Text
{
get { return (this as A).Text; }
set { text = value; }
}
}
Compiler say: The type 'B' already contains a definition for 'Text'.
Clarification: How to do so(but without class "Intermediate"):
abstract class A
{
public abstract string Text { get; }
}
class Intermediate : A
{
protected string text = "";
public override string Text
{
get { return text; }
}
}
class B : Intermediate
{
new public string Text
{
get { return (this as A).Text; }
set { text = value; }
}
}
If you want the property to be read-write in derived class, then it is impossible.
The property is a syntax sugar for PropertyType get_PropertyName() (when the property is readable) and void set_PropertyName(PropertyType value) (when the property is writable) methods. This line:
public abstract string Text { get; }
means:
public abstract string get_Text();
And this:
public override string Text{ get; set;}
means:
public override string get_Text()
{
// ...
}
public override void set_Text(string value)
{
// ...
}
Since there's no abstract set_Text method in base class, you can't override it.
You are defining the property Text twice in the same class. You are overriding it and using the keyword new. Delete the second copy of Text.
class B : A
{
private string text;
public override string Text{ get; set;}
}
You can sort of do this with an interface:
interface A
{
// The interface requires that Text is *at least* read only
string Text { get; }
}
class B : A
{
string text = "";
// Implement Text as read-write
public string Text
{
get { return text; }
set { text = value; }
}
}
If that's not going to work for you, you can simply add a TextEx property that is read-write:
public string TextEx
{
get { return text; }
set { text = value;
}
public string Text
{
get { return text; }
}
I have created a new Custom Control inheriting from Bar control of DevComponents.DotNetBar controls. Next, I have created a new dock tab in it and have added my other controls to it.
After I compile my Custom Control and add my created Custom Control in a new Windows Form, Dock Tab Controls are editable at design time.
I don't want that anybody can edit these controls (Dock Tab Controls) in design time. How can I disable editing the controls at design time from the form (not the same as editing the control itself)?
public partial class barFloorsGrouping : Bar
{
public barFloorsGrouping()
{
InitializeComponent();
}
[ReadOnly(true)]
public new System.Windows.Forms.AccessibleRole AccessibleRole
{
get { return base.AccessibleRole; }
private set { base.AccessibleRole = System.Windows.Forms.AccessibleRole.ToolBar; }
}
[Browsable(false), ReadOnly(true)]
public new bool AlwaysDisplayDockTab
{
get { return base.AlwaysDisplayDockTab; }
private set { base.AlwaysDisplayDockTab = true; }
}
[Browsable(false), ReadOnly(true)]
public new bool AlwaysDisplayKeyAccelerators
{
get { return base.AlwaysDisplayKeyAccelerators; }
private set { base.AlwaysDisplayKeyAccelerators = true; }
}
[ReadOnly(true)]
public new bool AntiAlias
{
get { return base.AntiAlias; }
private set { base.AntiAlias = true; }
}
[Browsable(false), ReadOnly(true)]
public new bool AutoCreateCaptionMenu
{
get { return base.AutoCreateCaptionMenu; }
}
[ReadOnly(true)]
public new bool AutoHide
{
get { return base.AutoHide; }
}
[Browsable(false), ReadOnly(true)]
public new bool AutoHideTabTextAlwaysVisible
{
get { return base.AutoHideTabTextAlwaysVisible; }
}
[Browsable(false), ReadOnly(true)]
public new bool AutoSyncBarCaption
{
get { return base.AutoSyncBarCaption; }
private set { base.AutoSyncBarCaption = true; }
}
[Browsable(false), ReadOnly(true)]
public new eBarType BarType
{
get { return base.BarType; }
private set { base.BarType = eBarType.DockWindow; }
}
[ReadOnly(true)]
public new bool CanAutoHide
{
get { return base.CanAutoHide; }
}
[ReadOnly(true)]
public new bool CanDockTab
{
get { return base.CanDockTab; }
private set { base.CanDockTab = false; }
}
[ReadOnly(true)]
public new bool CanUndock
{
get { return base.CanUndock; }
private set { base.CanUndock = false; }
}
[Browsable(false), ReadOnly(true)]
public new bool CloseSingleTab
{
get { return base.CloseSingleTab; }
}
[Browsable(false), ReadOnly(true)]
public new bool DisplayMoreItemsOnMenu
{
get { return base.DisplayMoreItemsOnMenu; }
private set { base.DisplayMoreItemsOnMenu = true; }
}
[ReadOnly(true)]
public new DockStyle Dock
{
get { return base.Dock; }
}
[Browsable(false), ReadOnly(true)]
public new bool DockTabCloseButtonVisible
{
get { return base.DockTabCloseButtonVisible; }
}
[Browsable(false), ReadOnly(true)]
public new bool FadeEffect
{
get { return base.FadeEffect; }
private set { base.FadeEffect = true; }
}
[Browsable(false), ReadOnly(true)]
public new eGrabHandleStyle GrabHandleStyle
{
get { return base.GrabHandleStyle; }
private set { base.GrabHandleStyle = eGrabHandleStyle.Caption; }
}
[Browsable(false), ReadOnly(true)]
public new eLayoutType LayoutType
{
get { return base.LayoutType; }
private set { base.LayoutType = eLayoutType.DockContainer; }
}
[Browsable(false), ReadOnly(true)]
public new bool MenuBar
{
get { return base.MenuBar; }
}
[Browsable(false), ReadOnly(true)]
public new bool TabNavigation
{
get { return base.TabNavigation; }
private set { base.TabNavigation = true; }
}
[Browsable(false), ReadOnly(true)]
public new bool WrapItemsDock
{
get { return base.WrapItemsDock; }
private set { base.WrapItemsDock = true; }
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
}
}
You must extend the design mode behavior by using ParentControlDesigner Class. ParentControlDesigner Class provides a base class for designers of controls that can contain child controls.
So, for achieve to your Goal, you must implement design-time services for a component by DesignerAttribute as the following (Just add below code before the written class):
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]
public partial class barFloorsGrouping : Bar
{
...
}
EDIT: As always I work in asp.net and webforms... This answer is for WebForms
You would need to override the GetDesignTimeHtml of the WebControl.
see MSDN docs
It sounds to me like you haven't done a lot of server control creation so you are in for a lot of fun...