I am new at Devexpress and need help
I am exporting to pdf but pdf colums not good need to autosize
how can I with code ?
here is my codes
private void navBarPdf_ElementClick(object sender, NavElementEventArgs e)
{
var save = new SaveFileDialog();
if (save.ShowDialog() == DialogResult.OK)
{
gridView1.ExportToPdf(save.FileName + ".pdf");
}
}
just right click on the header of your gridview and click BestFit(all columns) and the export your pdf
this works for me
Best
Related
I want to make a button that has a small icon (from FontAwesome) and text on it in my Xamarin app. I know I can just make a button but the problem is that I will require two fonts (the standard font for text and FontAwesome for the icon). Would anyone happen to know how I can do this, or if there is another way to achieve what I want?
Thanks!
As the json mentioned, I just made a simple implementation.
Create a new class inherit from Label, set FormattedText to combine the string(standard and icon), and add tap gesture on it .
public class MyLabel : Label
{
public delegate void MyHandler(object sender, EventArgs e);
public event MyHandler myEvent;
public MyLabel(string _myIcon, string _myText)
{
//build the UI
FormattedString text = new FormattedString();
text.Spans.Add(new Span { Text = _myIcon ,FontFamily= "FontAwesome5Free-Regular" });
text.Spans.Add(new Span { Text = _myText, TextColor = Color.Red ,BackgroundColor = Color.Blue });
FormattedText = text;
//tap event
TapGestureRecognizer tap = new TapGestureRecognizer();
tap.Tapped += (sender,e) => {
myEvent(sender,e);
};
}
}
Usage
MyLabel label = new MyLabel("", "test");
label.myEvent += (sener,e) =>
{
//do something when tapping
};
Content = label;
For how to integrate FontAwesome in Xamarin.Forms ,refer to
https://montemagno.com/xamarin-forms-custom-fonts-everywhere/.
I am picking a photo from photo library and i get the following
AlbumPath:
assets-library://asset/asset.JPG?id=106E99A1-4F6A-45A2-B320-B0AD4A8E8473&ext=JPG
Path:
/Users/myname/Library/Developer/CoreSimulator/Devices/21CB035B-A738-4F74-B121-2DB2A6B5372A/data/Containers/Data/Application/3081A323-98AF-4EF6-95B9-29D4C2CD8425/Documents/temp/IMG_20170408_111143.jpg
How do i assign this image to a button ? I tried the following.
var file = await CrossMedia.Current.PickPhotoAsync(
new Plugin.Media.Abstractions.PickMediaOptions
{
});
Button btn = new Button();
btn.Image = (Xamarin.Forms.FileImageSource)ImageSource.FromFile(file.Path);
No image is displayed on the button. Any help help is appreciated.
Thank you.
Once you deploy the application the app will not have access to your mac. For the application to use the picture it will need to be a bundled resource within the iOS application. Below is a simple example of using images within an iOS app. You'll definitely want to consider just adding a gesture listener to your image instead of making it a button though. If you try to just use the image on a button you'll have to do some styling adjustments to get it to look clean.
Image Setup
Put image in iOS Resource folder
Make sure bundledresource is selected from image properties.
Image Button
public class ImageButton : ContentPage
{
private Button _imageBtn = new Button { Image = "icon.png", Text = "Sample button" };
public ImageButton()
{
Content = new StackLayout
{
Children =
{
_imageBtn
}
};
}
}
Image with TapGesture
public class ImageButton : ContentPage
{
private Image _imageBtn = new Image { Source = "icon.png" };
private TapGestureRecognizer _imageTap = new TapGestureRecognizer();
public ImageButton()
{
_imageBtn.GestureRecognizers.Add(_imageTap);
Content = new StackLayout
{
Children =
{
_imageBtn
}
};
_imageTap.Tapped += (s, e) =>
{
// handle the tap
};
}
}
I have graph in my page, build with the help of jqplot. And the graph lies within the update panel.Now I need to export that graph to the excel. But while I export that graph only the Title get exported but not the graph.So, I am stuck on this.
I will be very thankful to the answer for exporting the chart build by jqplot within the update panel to excel
Code used for export:
protected void btnExcel_Click(object sender, ImageClickEventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=ProjectTarget_" + CampaignID + ".xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
// LoadMileStones(currMileStone);
TableLists.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
Could anyone please help me , how I can programmatically increase or decrease the font size of web browser control in windows phone 7 c sharp . I need this to implement the zoom functionality in web browser control.
here is my code
private void btn_zoomin_click(object sender, EventArgs e)
{
double fs = webBrowser1.FontSize;
webBrowser1.FontSize = fs+10;
}
But the font is not being changed at all.
Any kind of help will be appreciated.
Many thanks,
Munazza
Yes there is a solution, you can fire a script inside the html page to enlarge the font by using the webBrowser's "InvokeScript" , here is a sample:
webBrowser1.InvokeScript("ChangeFontSize","12");
TO DO : a script inside the html :
<script type="text/javascript">
function ChangeFontSize(size) {
.....
....
return true;
}
<script/>
I don't think it's supposed to work this way.
The user can zoom in and out like he does in the Internet Explorer, but you can't change the font size.
You could, technically, get the html file that you want to display, parse it and if the fontsize is defined inline, you could change it and then display the new html file in the WebBrowser control, but I don't think that's a very good idea.
You have to use WebBrowser.InvokeScript:
// Initial text size
int textSize = 100;
private void TextPlusOnClick(object sender, EventArgs e)
{
textSize *= 2;
string szfn = "{styleText = \"body { -ms-text-size-adjust:" + textSize + "% }\";styleTextNode = document.createTextNode(styleText);styleNode = document.createElement(\"style\");styleNode.appendChild(styleTextNode);document.getElementsByTagName(\"head\")[0].appendChild(styleNode);};";
webBrowser.InvokeScript("eval", szfn);
}
private void TextMinusOnClick(object sender, EventArgs e)
{
textSize /= 2;
string szfn = "{styleText = \"body { -ms-text-size-adjust:" + textSize + "% }\";styleTextNode = document.createTextNode(styleText);styleNode = document.createElement(\"style\");styleNode.appendChild(styleTextNode);document.getElementsByTagName(\"head\")[0].appendChild(styleNode);};";
webBrowser.InvokeScript("eval", szfn);
}
See a description on the text size adjust property and this post on MSDN.
I have a wp7 with some buttons in the application bar.
When each button is pressed I change the menuItems of the application bar's menu.
After this, I want to automatically open the menu when an application bar button is pressed.
But it seems that the SDK doesn't allow me to do that.
Do you know any work around?
I was thinking, if the above is not possible, to simulate a user finger click at the bottom right corner of the screen to open the menu. Any ideas on that?
Thanx in advance
It's possible to change the Application Bar Menu Items in response to an Icon Button click as demonstrated in the code below.
There isn't a way to forcibly open (or close) the application bar through code through.
It also isn't possible to simulate a finger click on the application bar as this isn't part of the actual page. Note that even if possible any click would need to be in the top right or bottom left if the device was in a landscape orientation.
Here's some code which demonstrates changing the menu items:
public partial class MainPage : PhoneApplicationPage
{
private ApplicationBar appbar;
public MainPage()
{
InitializeComponent();
Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
appbar = new ApplicationBar();
var ib1 = new ApplicationBarIconButton(new Uri("/images/one.png", UriKind.Relative)) { Text = "Option one" };
ib1.Click += new EventHandler(ShowMenuOption1);
var ib2 = new ApplicationBarIconButton(new Uri("/images/two.png", UriKind.Relative)) { Text = "Option two" };
ib2.Click += new EventHandler(ShowMenuOption2);
appbar.Buttons.Add(ib1);
appbar.Buttons.Add(ib2);
// Show menu option 1 as default
DisplayMenuOption1();
this.ApplicationBar = appbar;
}
private void DisplayMenuOption1()
{
appbar.MenuItems.Clear();
var itemA = new ApplicationBarMenuItem("AAAA");
var itemB = new ApplicationBarMenuItem("BBB");
appbar.MenuItems.Add(itemA);
appbar.MenuItems.Add(itemB);
}
private void DisplayMenuOption2()
{
appbar.MenuItems.Clear();
var itemC = new ApplicationBarMenuItem("CCCC");
var itemD = new ApplicationBarMenuItem("DDDD");
appbar.MenuItems.Add(itemC);
appbar.MenuItems.Add(itemD);
}
private void ShowMenuOption2(object sender, EventArgs e)
{
DisplayMenuOption2();
}
private void ShowMenuOption1(object sender, EventArgs e)
{
DisplayMenuOption1();
}
}
As far as I'm aware this capability has not been exposed as yet. It wasn't possible during beta and I've not noticed anything that's changed since that would allow it. You could always comment on the their suggestions forum or raise it on connect (vs/wpdt).