HOW TO ADD JCHECKBOX TO A JCOMBOBOX - checkbox

I need to do a menu with checkboxes inside, I cant do it! I checked all the java api documentation and dont exist examples. Help...
JComboBox<JCheckBox> cb = new JComboBox<JCheckBox>();
cb.add(cbEasy = new JCheckBox("EASY", false));
cb.add(cbDifficult = new JCheckBox("DIFFICULT", false));
In the interface its empty the combobox...

Related

setting URL as mediaElement source

I keep getting an "object reference not set to an instance of an object" and i have absolutely no idea why!
MediaElement1.Source = New URI(trackstream(0), UriKind.Absolute)
If i mouseover to check everything it seems fine, that variable position contains a direct link to an mp3, It even says if i mouseover it that the Source has been set to that URL but then i get this error.
i am just trying to set url as the first in a list that i have downloaded from a textfile previously, then put into that array. I have tried changing the urlkind and omitting it.
This works:
public MainWindow()
{
string[] trackstream = new string[] { #"C:\Users\Public\Music\Sample Music\sound.wma" };
InitializeComponent();
media.Source = new Uri(trackstream[0], UriKind.Absolute);
}

How to detect the sender(button) of dynamical created bindings

I create some RibbonButtons dynamically and add them to a group according to an xml file. The follwoing function is carried out as often as entries found in the xml file.
private void ExtAppsWalk(ExternalAppsXml p, AppsWalkEventArgs args)
{
RibbonButton rBtn = new RibbonButton();
rBtn.Name = args.Name;
Binding cmdBinding = new Binding("ExtAppCommand");
rBtn.SetBinding(RibbonButton.CommandProperty, cmdBinding);
Binding tagBinding = new Binding("UrlTag");
tagBinding.Mode = BindingMode.OneWayToSource;
rBtn.SetBinding(RibbonButton.TagProperty, tagBinding);
rBtn.Label = args.Haed;
rBtn.Tag = args.Url;
rBtn.Margin = new Thickness(15, 0, 0, 0);
MyHost.ribGrpExtern.Items.Add(rBtn);
}
I tried to use the Tag property to store the Url's to be started when the respective button is clicked. Unfortunately the binding to the Tag property gives me the last inserted Url only.
What would be the best way to figure out which button is hit or to update the Tag property.
The datacontext is by default the context of the Viewmodel. The RibbonGroup to which the Buttons are added is created in the xaml file at designtime. I use that construct:
MyHost.ribGrpExtern.Items.Add(rBtn);
to add the buttons. It maight not really be conform with the mvvm pattern. May be someone else has a better idea to carry that out.
I foud a solution for my problem here and use the RelayCommand class. So I can pass objects (my Url) to the CommandHandler.
RibbonButton rBtn = new RibbonButton();
rBtn.Name = args.Name;
Binding cmdBinding = new Binding("ExtAppCommand");
rBtn.SetBinding(RibbonButton.CommandProperty, cmdBinding);
rBtn.CommandParameter = (object)args.Url;
private void ExtAppFuncExecute(object parameter)
{
if (parameter.ToString().....//myUrl

I can't get my SharePoint ListItem Fields

I want to show all fields of a certain ListItem. This includes LookUpFields and ChoiceFields. But I only seem to be able to show Textfields, like Title. How can I show all fields of my ListItem?
The problem is that I get an error when I try to show other fields of a listitem the way I got 'Title' to show, as if the strings I type in don't exist as fields in that listitem. But they do exist and are populated with values!
What is good way to show custom fields of a listitem without getting ObjectReference errors?
Also I get this error: The given key was not present in the dictionary.
private void foo()
{
using (ClientContext context = new ClientContext(ApplicationContext.Current.Url))
{
_list = context.Web.Lists.GetByTitle("MyList").Title);
_items = _list.GetItems(CamlQuery.CreateAllItemsQuery());
context.Load(_items);
context.ExecuteQueryAsync(
new ClientRequestSucceededEventHandler(OnListItemsRequestSucceeded),
new ClientRequestFailedEventHandler(OnListItemsRequestFailed));
}
}
private void OnListItemsRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args)
{
// this is not called on the UI thread
Dispatcher.BeginInvoke(ShowListItemDetails);
}
public void ShowListItemDetails()
{
foreach (ListItem i in _items)
{
TextBox_Details.Text += i["Title"].ToString() + Environment.NewLine;
// Now the rest of the fields of this item.
}
}
Edit: What also is a big problem is I cant get the debugger working. This code is running as a Silverlight webpart on a local Sharepoint site. I attach the debugger to the iexplorer.exe but it won't break.
If I could get the debugger to work it would be a great help indeed.
you have tell the query what all fields you need to pull from lists
CamlQuery camlQuery = new CamlQuery();
camlQuery.ListItemCollectionPosition = itemPosition;
camlQuery.ViewXml =
#"<View>
<ViewFields>
<FieldRef Name='Title'/>
<FieldRef Name='Category'/>
<FieldRef Name='Estimate'/>
</ViewFields>
<RowLimit>10</RowLimit>
</View>";
ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
for more details
http://msdn.microsoft.com/en-us/library/ee857094.aspx#SP2010ClientOM_Accessing_Large_Lists
To get item properties you will need to specify all the item properties you need in the second parameter of the ClientContext.Load method
e.g
string server = "http://localhost";
ClientContext context = new ClientContext(server);
Web web = context.Web;
var spList = web.Lists.GetByTitle("MyTitle");
CamlQuery query = new CamlQuery();
var items = spList.GetItems(query);
context.Load(items,
itema => itema.Include(
item => item,
item => item["ComplexProperty"]));
context.ExecuteQuery();`

Adding new item to pageCollection's object

i am working with an pageCollectionin silverlight ,i have some remove and addition work in to the pagedviewcollection's object
i was able to remove from collection as below
_pageCollection.RemoveAt(_index);
but i am not able add an item to the pageCollection .how to add an item to the _pageCollection. i feel it should be dealt with below code
_pageCollection.AddNew();
but i amnot able to get how to proceed?
If you use a PagedCollectionView you have to set a source IEnumerable. If you add it to this collection it will work (assuming that your PCV is working with a list of Products which have an id).
myPagedCollectionView = new PagedCollectionView(myCollection);
myCollection.Add(new Product(){Id=5});
If you work with AddNew you have to do it like this :
var obj = (Product)myPagedCollectionView.AddNew();
obj.Id = 5;
Hope this is what you needed.

Showing Bitmap Images in WPF via C#

What I am trying to do is so simple but I am having a hard time making it work. I saw some posts along the same lines but I still have questions.
I have a MenuItem object called mnuA. All I want is set the icon property programatically in C#. I have tried the following
a) mnuA.Icon = new BitmapImage{UriSource = new Uri(#"c:\icons\A.png")};
Results: Instead of showing the actual icon, I get the class name (System.Windows.Media.Imaging.BitmapImage)
b) mnuA.Icon = new BitmapImage(new Uri(#"c:\icons\A.png"));
Results: Instead of showing the actual icon, I get the path of the image (file:///c:/icons/A.png)
What am I doing wrong? Do I really need a converter class for something simple like this?
Try this:
Image img = new Image();
img.Source = new BitmapImage(new Uri(#"c:\icons\A.png"));
mnuA.Icon = img;
Might be a long shot, but try something like:
Uri u = new Uri(...); mnuA.Icon = new
BitmapImage(u);
What it seems its happening is that your icon is getting converted to a string.

Resources