Search Results

Search found 4334 results on 174 pages for 'sender'.

Page 23/174 | < Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >

  • [C#] How to use delegate to perform callback between caller and web service helper class?

    - by codemonkie
    I have 2 classes A and B, where they belongs to the same namespace but resides in seperate files namely a.cs and b.cs, where class B essentially is a helper wrapping a web service call as follow: public class A { public A() // constructor { protected static B b = new B(); } private void processResult1(string result) { // come here when result is successful } private void processResult2(string result) { // come here when result is failed } static void main() { b.DoJobHelper(...); } } public class B { private com.nowhere.somewebservice ws; public B() { this.ws = new com.nowhere.somewebservice(); ws.JobCompleted += new JobCompletedEventHandler(OnCompleted); } void OnCompleted(object sender, JobCompletedEventArgs e) { string s; Guid taskID = (Guid)e.UserState; switch (s) { case "Success": // Call processResult1(); break; case "Failed": // Call processResult2(); break; default: break; } } public void DoJobHelper() { Object userState = Guid.NewGuid(); ws.DoJob(..., userState); } } (1) I have seen texts on the net on using delegates for callbacks but failed to apply that to my case. All I want to do is to call the appropriate processResult() method upon OnCompleted() event, but dunno how to and where to declare the delegate: public delegate void CallBack(string s); (2) There is a sender object passed in to OnCompleted() but never used, did I miss anything there? Or how can I make good use of sender? Any helps appreciated.

    Read the article

  • How to keep a trace of a record inside a nested repeater?

    - by Amokrane
    Hi, I have the following implementation: As you can see I have a repeater (listing the Machines) and a nested repeater (listing the WindowsServices inside each Machine). For each Windows Service I can perform an action using a button. However, to perform this action I need to know which Machine and which WindowsService are concerned. This is my code: protected void Page_Init(object sender, EventArgs e) { rptMachine.ItemDataBound += new RepeaterItemEventHandler(rptMachine_ItemDataBound); } protected void Page_Load(object sender, EventArgs e) { // bind the Machine repeater rptMachine.DataSource = _monitoringService.Machines; rptMachine.DataBind(); } protected void rptMachine_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Repeater nestedRepeater = (Repeater) e.Item.FindControl("rptWindowsService"); nestedRepeater.DataSource = ((IMachine) e.Item.DataItem).WindowsServices; nestedRepeater.DataBind(); Button btnActionInner = null; // bind the action button situated inside the nested repeater foreach(RepeaterItem ri in nestedRepeater.Items) { if((Button)ri.FindControl("btnAction") != null) { btnActionInner = (Button) ri.FindControl("btnAction"); btnActionInner.CommandName = "ActionState"; btnActionInner.CommandArgument = strWindowsService; } } } } protected void rptWindowsService_ItemCommand(object source, RepeaterCommandEventArgs e) { // do the specific action stop/run for the windows service if (e.CommandName == "ActionState") { if(((Button)(e.CommandSource)).Text.Equals("Stop")) { } else if(((Button)(e.CommandSource)).Text.Equals("Run")) { } } } } } So basically I need to know (inside rptWindowsService_ItemCommand) what is the pair that is concerned by the operation. What's the best way to do that? Don't hesitate to ask for more clarifications! Thanks

    Read the article

  • KeyUp processed for wrong control

    - by Mikael
    I have made a simple test application for the issue, two winforms each containing a button. The button on the first form opens the other form when clicked. It also subscribes to keyup events. The second form has its button set as "AcceptButton" and in the Clicked event we sleep for 1s and then set DialogResult to true (the sleep is to simulate some processing done) When enter is used to close this second form the KeyUp event of the button on the first form is triggered, even though the key was released well before the second had passed so the second form was still shown and focused. If any key other then enter is pressed in the second form the event is not triggered for the button on the first form. First form: public Form1() { InitializeComponent(); buttonForm2.KeyUp += new KeyEventHandler(cntKeyUp); } void cntKeyUp(object sender, KeyEventArgs e) { MessageBox.Show(e.KeyCode.ToString()); } private void buttonForm2_Click(object sender, EventArgs e) { using (Form2 f = new Form2()) { f.ShowDialog(); } } Second form: private void button1_Click(object sender, EventArgs e) { Thread.Sleep(1000); this.DialogResult = DialogResult.OK; } Does anyone know why the event is triggered for the button on the non active form and what can be done to stop this from happening?

    Read the article

  • Accesing WinCE ComboBox DroppedDown property (.NET CF 2.0)

    - by PabloG
    I'm implementing custom behavior sub-classing the form controls, but I cannot manage to access the DroppedDown property of the ComboBox. Looking in the help, it's supposed to be supported in CF.NET 2.0: using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; namespace xCustomControls { public partial class xComboBox : System.Windows.Forms.ComboBox { private ComboBox comboBox1; public xComboBox() { InitializeComponent(); this.KeyDown += new KeyEventHandler(this.KeyDownHandler); } private void KeyDownHandler(object sender, KeyEventArgs e) { // DroppedDown doesn't appear in the IntelliSense of ComboBox. // or this.comboBox1. if (((ComboBox)sender).DroppedDown) // fail! return; switch (e.KeyData) { case Keys.Up: case Keys.Enter: case Keys.Down: e.Handled = true; this.Parent.SelectNextControl((Control)sender, e.KeyData != Keys.Up, true, true, true); ... fails with 'System.Windows.Forms.ComboBox' does not contain a definition for 'DroppedDown' and no extension method 'DroppedDown' accepting a first argument of type 'System.Windows.Forms.ComboBox' could be found How can I access the property? TIA, Pablo

    Read the article

  • AJAX - ASP.NET - Timer delay problem

    - by Julian
    Hi, I'm trying to make an webapplication where you see an Ajax countdown timer. Whenever I push a button the countdown should go back to 30 and keep counting down. Now the problem is whenever I push the button the timer keeps counting down for a second or 2 and most of the time after that the timer keeps standing on 30 for to long. WebForm code: <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="geen verbinding"></asp:Label> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> <br /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel> <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick"> </asp:Timer> </form> Code Behind: static int timer = 30; protected void Page_Load(object sender, EventArgs e) { Label1.Text = timer.ToString(); } protected void Timer1_Tick(object sender, EventArgs e) { timer--; } protected void Button1_Click(object sender, EventArgs e) { timer = 30; } Hope somebody knows what the problem is and if there is anyway to fix this. Thanks in advance!

    Read the article

  • sorting filtered data in asp.net listview

    - by user791345
    I've created a listview that's filled up with a list of guitars from the database on page load like so: protected void Page_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["GuitarsLTDBConnectionString"].ToString()); SqlCommand cmd = new SqlCommand("SELECT * FROM Guitars", con); SqlDataAdapter da = new SqlDataAdapter(cmd.CommandText, con); DataTable dt = new DataTable(); da.Fill(dt); lvGuitars.DataSource = dt; lvGuitars.DataBind(); } The following code filters that list of guitars by a certain Make when the user checks the checkbox corresponding to that make protected void chkOrgs_SelectedIndexChanged(object sender, EventArgs e) { DataTable dt = (DataTable)lvGuitars.DataSource; DataView dv = new DataView(dt); if (chkOrgs.SelectedValue == "Gibson") { dv.RowFilter = "Make = 'Gibson' OR Make='Fender'"; } lvGuitars.DataSource = dv.ToTable(); lvGuitars.DataBind(); } Now, what I want to do is be able to sort the latest data that is present within the listview. Meaning, if sort is clicked before filtering, the it should sort all data. If sort is clicked after filtering, it should sort the filtered data. I'm using the following code, which is triggered upon a LinkButton click protected void lnkSortResults_Click(object sender, EventArgs e) { DataTable dt = (DataTable)lvGuitars.DataSource; DataView dv = new DataView(dt); dv.Sort = "Make ASC"; lvGuitars.DataSource = dv.ToTable(); lvGuitars.DataBind(); } The problem is that all the data that the listview was loaded with before any filtering is sorted, and not the latest filtered data. How can I change this code so that the latest data available in the listview is the one that's sorted? Thanks

    Read the article

  • Why am I getting "Message sent to deallocated object" in Objective-C?

    - by Dave C
    I have several buttons on my app that are being created dynamically. They are all pointed at the button click event when pressed. When the button pressed method is called, the sender's tag (int value) is parsed into the controller's house ID. It works with one of the buttons — the first one created, to be specific — but the others throw the following error: -[CFNumber intValue]: message sent to deallocated instance 0xc4bb0ff0 I am not releasing these buttons anywhere in my code. I haven't set them to autorelease or anything like that. I'm just wondering why they are doing this on the click. The button click event: - (IBAction) ButtonClick: (id) sender { HouseholdViewController *controller = [[HouseholdViewController alloc] initWithNibName:@"HouseholdViewController" bundle:nil]; controller.delegate = self; controller.HouseID = [(NSInteger)[(UIButton *)sender tag] intValue]; //this line throws an error controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:controller animated:YES]; [controller release]; } Where I am creating the buttons: UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(MyLongInScreenCoords, MyLatInScreenCoords, 50, 50); UIImage *buttonImageNormal = [UIImage imageNamed:@"blue_pin.png"]; UIImage *strechableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:50 topCapHeight:50]; [button setBackgroundImage:strechableButtonImageNormal forState:UIControlStateNormal]; [self.view addSubview:button]; button.tag = [NSNumber numberWithInt:[[words objectAtIndex: i] intValue]]; ButtonPoints[CurrentHouseCount][0] = button; ButtonPoints[CurrentHouseCount][1] = [NSValue valueWithCGPoint:CGPointMake(MyActualLat, MyActualLong)]; [button addTarget:self action:@selector(ButtonClick:) forControlEvents:UIControlEventTouchUpInside]; CurrentHouseCount++;

    Read the article

  • Help decoupling Crystal Report from CrystalReportViewer

    - by John at CashCommons
    I'm using Visual Studio 2005 with VB.NET. I have a number of Crystal Reports, each with their own associated dialog resource containing a CrystalReportViewer. The class definitions look like this: Imports System.Windows.Forms Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared Public Class dlgForMyReport Private theReport As New myCrystalReport Public theItems As New List(Of MyItem) Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click Me.DialogResult = System.Windows.Forms.DialogResult.OK Me.Close() End Sub Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click Me.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Close() End Sub Private Sub dlgForMyReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load theReport.SetDataSource(theItems) 'Do a bunch of stuff here to set data items in theReport Me.myCrystalReportViewer.ReportSource = theReport End Sub End Class I basically instantiate the dialog, set theItems to the list I want, and call ShowDialog. I now have a need to combine several of these reports into one report (possibly like this) but the code that loads up the fields in the report is in the dialog. How would I go about decoupling the report initialization from the dialog? Thanks!

    Read the article

  • ASP.NET:Paging when deleting rows

    - by Niels Bosma
    I have a datagrid where a row can be deleted (using ajax). I'm have problem with the pager in the following scenario: Lets say my PageSize is 10, I have 101 rows so that's 11 pages with the last page with an single element. Let no assume that I'm on page 10 (PageIndex=9) and delete a row. Then I go to the 11'th page (who's now empty and doesn't really exist). ASP now shows me the EmptyDataTemplate and no pager so I can't go back. My approach (which isn't working) is to detect this scenario and step one page back: public void Bind() { gridMain.DataBind(); } public void SetPage(int page) { gridMain.PageIndex = page; gridMain.DataBind(); } protected void ldsGridMain_Selecting(object sender, LinqDataSourceSelectEventArgs e) { selectArgs = e; e.Result = (new EnquiryListController()).GetEnquiryList(OnBind(this), supplier); } protected void ldsGridMain_Selected(object sender, LinqDataSourceStatusEventArgs e) { totalRows = selectArgs.Arguments.TotalRowCount; //Detect if we need to update the page: if (gridMain.PageIndex > 0 && (gridMain.PageSize * gridMain.PageIndex + 1) > totalRows) SetPage(gridMain.PageIndex - 1); } protected void gridMain_PageIndexChanging(object sender, GridViewPageEventArgs e) { SetPage(e.NewPageIndex); } I can see that SetPage is called with the the right page index, but the databind doesn't seem to called as I still get the EmptyDataTemplate.

    Read the article

  • commitAnimations is not resizing my UIImageView subview

    - by AaronG
    I have created a UIView as a subview and to that subview I have added a UIImageView as a subview. UIView *viewCreated; UIButton *buttonCreated; UIImageView *imageViewCreated; CGRect myFrame = CGRectMake(0, 0, 1024, 1024); viewCreated = [[UIView alloc] initWithFrame:myFrame]; [viewCreated setTag:intTag]; viewCreated.backgroundColor = [UIColor redColor]; [self.view addSubview:viewCreated]; [self randomize]; UIImage *d1Image = [UIImage imageNamed:[NSString stringWithFormat:@"image%d.png", randomNumber]]; imageViewCreated = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f,0.0f,1024.0f, 1024.0f)]; [imageViewCreated setImage:[UIImage imageNamed:[NSString stringWithFormat:@"image%d.png", randomNumber]]]; [viewCreated addSubview:imageViewCreated]; //[imageViewCreated release]; return [viewCreated autorelease]; But when this code executes only the first subview is animated and resized. The UiimageView moves 200 pixels to the left but does not get resized. NSLog(@"sender tag %i",[sender tag]); UIView *currentView = [self.view viewWithTag:[sender tag]]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1.5]; currentView.frame = CGRectMake(-200, 0,40, 102); [UIView commitAnimations]; I am pretty sure am I not creating the subviews correctly programmatically, because when I do it in Interface Builder it works as expected. Do I have to do something specific to actually attach the behavior of the second subview to the first subview?

    Read the article

  • Deselect dates in ASP.NET Calendar Control

    - by yomismo
    I'm trying to select and de-select dates on a C# Web Calendar control. The problem I have is that I can select or deselect dates except when there is only a single date selected. Clicking on it does not trigger the selection changed event, so Ineed to do something on the dayrender event but I'm not sure what or how. Edit: Added the Pre_Render event code. This seems to work now, however it seems a little bit erratic,e.g. select date A : OK Select date B :OK deselect them both: OK select date A: Does not work, need to select it twice deselect date A : Ok Select Date C: dates A and c are selected @John Yes, I am aware that the control is part of the .NET 2.0 framework and nothing to do with C# per se. Code so far: public static List<DateTime> list = new List<DateTime>(); protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { if (e.Day.IsSelected == true) { list.Add(e.Day.Date); } Session["SelectedDates"] = list; } protected void Calendar1_SelectionChanged(object sender, EventArgs e) { DateTime selection = Calendar1.SelectedDate; if (Session["SelectedDates"] != null) { List<DateTime> newList = (List<DateTime>)Session["SelectedDates"]; foreach (DateTime dt in newList) { Calendar1.SelectedDates.Add(dt); } if (searchdate(selection, newList)) { Calendar1.SelectedDates.Remove(selection); } list.Clear(); } } public bool searchdate(DateTime date, List<DateTime> dates) { var query = from o in dates where o.Date == date select o; if (query.ToList().Count == 0) { return false; } else { return true; } } protected void Calendar1_PreRender(object sender, EventArgs e) { if (Calendar1.SelectedDates.Count == 1) { foreach (DateTime dt in list) { if (searchdate(dt, list) && list.Count == 1) { Calendar1.SelectedDates.Clear(); break; } } } }

    Read the article

  • iPhone View Switching basics.

    - by Daniel Granger
    I am just trying to get my head around simple view switching for the iPhone and have created a simple app to try and help me understand it. I have included the code from my root controller used to switch the views. My app has a single toolbar with three buttons on it each linking to one view. Here is my code to do this but I think there most be a more efficient way to achieve this? Is there a way to find out / remove the current displayed view instead of having to do the if statements to see if either has a superclass? I know I could use a tab bar to create a similar effect but I am just using this method to help me practice a few of the techniques. -(IBAction)switchToDataInput:(id)sender{ if (self.dataInputVC.view.superview == nil) { if (dataInputVC == nil) { dataInputVC = [[DataInputViewController alloc] initWithNibName:@"DataInput" bundle:nil]; } if (self.UIElementsVC.view.superview != nil) { [UIElementsVC.view removeFromSuperview]; } else if (self.totalsVC.view.superview != nil) { [totalsVC.view removeFromSuperview]; } [self.view insertSubview:dataInputVC.view atIndex:0]; } } -(IBAction)switchToUIElements:(id)sender{ if (self.UIElementsVC.view.superview == nil) { if (UIElementsVC == nil) { UIElementsVC = [[UIElementsViewController alloc] initWithNibName:@"UIElements" bundle:nil]; } if (self.dataInputVC.view.superview != nil) { [dataInputVC.view removeFromSuperview]; } else if (self.totalsVC.view.superview != nil) { [totalsVC.view removeFromSuperview]; } [self.view insertSubview:UIElementsVC.view atIndex:0]; } } -(IBAction)switchToTotals:(id)sender{ if (self.totalsVC.view.superview == nil) { if (totalsVC == nil) { totalsVC = [[TotalsViewController alloc] initWithNibName:@"Totals" bundle:nil]; } if (self.dataInputVC.view.superview != nil) { [dataInputVC.view removeFromSuperview]; } else if (self.UIElementsVC.view.superview != nil) { [UIElementsVC.view removeFromSuperview]; } [self.view insertSubview:totalsVC.view atIndex:0]; } }

    Read the article

  • Manage multiple UDP calls

    - by rayman
    Hi all, I would like to have an advice for this issue: I am using Jbos 5.1.0, EJB3.0 I have system, which sending requests via UDP'S to remote modems, and suppose to wait for an answer from the target modem. the remote modems support only UDP calls, therefor I o design asynchronous mechanism. (also coz I want to request X modems parallel) this is what I try to do: all calls are retrieved from Data Base, then each call will be added as a message to JMS QUE. let's say i will set X MDB'S on that que, so I can work asynchronous. now each MDB will send UDP request to the IP-address(remote modem) which will be parsed from the que message. so basicly each MDB, which takes a message is sending a udp request to the remote modem and [b]waiting [/b]for an answer from that modem. [u]now here is the BUG:[/u] could happen a scenario where MDB will get an answer, but not from the right modem( which it requested in first place). that bad scenario cause two wrong things: a. the sender which sent the message will wait forever since the message never returned to him(it got accepted by another MDB). b. the MDB which received the message is not the right one, and probablly if it was on a "listener" mode, then it supposed to wait for an answer from diffrent sender.(else it wouldnt get any messages) so ofcourse I can handle everything with a RETRY mechanisem. so both mdb's(the one who got message from the wrong sender, and the one who never got the answer) will try again, to do thire operation with a hope that next time it will success. This is the mechanism, mybe you could tell me if there is any design pattren, or any other effective solution for this problem? Thanks, ray.

    Read the article

  • Am I using Settings in .NET correctly?

    - by Sergio Tapia
    Here's what I'm doing. I have three properties: MomsBackground, DadsBackground and ChosenBackground. When Momsbackground is selected in the program, I set the ChosenBackground string according to what item the user has clicked (either "Mom" or "Dad"). Then on Form_Load() I use a switch case for the ChosenBackground string and according to that select This.BackgroundColor to MomsBackground or DadsBackground. Code below: Am I using this as it was intended? Sorry, codes there now. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void momToolStripMenuItem_Click(object sender, EventArgs e) { this.BackColor = Properties.Settings.Default.MomFormColor; Properties.Settings.Default.SelectedTheme = "Mom"; Properties.Settings.Default.Save(); } private void dadToolStripMenuItem_Click(object sender, EventArgs e) { this.BackColor = Properties.Settings.Default.DadFormColor; Properties.Settings.Default.SelectedTheme = "Dad"; Properties.Settings.Default.Save(); } private void Form1_Load(object sender, EventArgs e) { switch (Properties.Settings.Default.SelectedTheme) { case "Mom": this.BackColor = Properties.Settings.Default.MomFormColor; break; case "Dad": this.BackColor = Properties.Settings.Default.DadFormColor; break; default: break; } } } }

    Read the article

  • Updating MS Access Database from Datagridview

    - by Peter Roche
    I am trying to update an ms access database from a datagridview. The datagridview is populated on a button click and the database is updated when any cell is modified. The code example I have been using populates on form load and uses the cellendedit event. private OleDbConnection connection = null; private OleDbDataAdapter dataadapter = null; private DataSet ds = null; private void Form2_Load(object sender, EventArgs e) { string connetionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='C:\\Users\\Peter\\Documents\\Visual Studio 2010\\Projects\\StockIT\\StockIT\\bin\\Debug\\StockManagement.accdb';Persist Security Info=True;Jet OLEDB:Database Password="; string sql = "SELECT * FROM StockCount"; connection = new OleDbConnection(connetionString); dataadapter = new OleDbDataAdapter(sql, connection); ds = new DataSet(); connection.Open(); dataadapter.Fill(ds, "Stock"); connection.Close(); dataGridView1.DataSource = ds; dataGridView1.DataMember = "Stock"; } private void addUpadateButton_Click(object sender, EventArgs e) { } private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { dataadapter.Update(ds,"Stock"); } catch (Exception exceptionObj) { MessageBox.Show(exceptionObj.Message.ToString()); } } The error I receive is Update requires a valid UpdateCommand when passed DataRow collection with modified rows. I'm not sure where this command needs to go and how to reference the cell to update the value in the database.

    Read the article

  • I want to read program content from command line.

    - by Alexandre Dominos
    I am trying to update a program which was wrotten in 1995 with pascal or c. I am not sure about programming language. Command line program. Now I am coded in C#. And I want to read program command line content. Is it possible? I tried something. But not succesfull. They are: private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { // Redirect the output stream of the child process. p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = "osl.exe"; p.Start(); logs.AppendText("Timer Started\n"); timer1.Enabled = true; } private void timer1_Tick(object sender, EventArgs e) { // write somethingg and read what is the program doing on command line? // What is the program printint? etc... // I try this code but not enough for mo. // logs.AppendText("d:" + p.StandardOutput.ReadToEnd()+"\n"); } private void p_Exited(object sender, EventArgs e) { timer1.Enabled = false; } i am open to any idea in java,cpp,c,c#.

    Read the article

  • Dynamcally resizing an open Accordion

    - by alavers
    I have an Accordion and the height of its content can be dynamically resized. I would like to see the Accordion dynamically respond to the child item's height, but I'm having trouble doing this. <lt:Accordion Name="MyAccordion" SelectionMode="ZeroOrOne" HorizontalAlignment="Stretch"> <lt:AccordionItem Name="MyAccordionItem" Header="MyAccordion" IsSelected="True" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch"> <StackPanel> <Button Content="Grow" Click="Grow"/> <Button Content="Shrink" Click="Shrink"/> <TextBox Name="GrowTextBox" Text="GrowTextBox" Height="400" Background="Green" SizeChanged="GrowTextBox_SizeChanged"/> </StackPanel> </lt:AccordionItem> </lt:Accordion> private void Grow(object sender, System.Windows.RoutedEventArgs e) { GrowTextBox.Height += 100; } private void Shrink(object sender, System.Windows.RoutedEventArgs e) { GrowTextBox.Height -= 100; } private void GrowTextBox_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e) { MyAccordion.UpdateLayout(); MyAccordionItem.UpdateLayout(); } Mind you, if I collapse and then re-open the accordion, it takes shape just the way I want, but I'd like this resizing to occur immediately when the child resizes. I feebly attempted to fix this by adding a SizeChanged event handler that calls UpdateLayout() on the Accordion and AccordionItem, but this doesn't have any visual effect. I can't figure out where proper resizing takes place inside the Accordion control. Does anyone have an idea?

    Read the article

  • placing pop up based on the mouse position(x,y)RSS Feed

    - by prince23
    hi, right now i am showing pop at the botton of the screen. i need to change them according to the value(x,y) whhere i have moved the mouse here i need to get the MouseEventArgs e postion that is its x:value and y:value based on that i need to place the pop up in the screen i need to get the mouse x, y postion? is it possiable to get its value? private void DG_LoadingRow(object sender, DataGridRowEventArgs e) { DataGridRow row = e.Row; int index = 0; foreach (DataGridColumn colGrid in DG.Columns) { if(colGrid .Header == "ID" || colGrid .Header == "Name") { FrameworkElement cellContent = colGrid .GetCellContent(e.Row); DataGridCell cell = cellContent.Parent as DataGridCell; cell.MouseEnter -= cell_MouseEnter; cell.MouseEnter += new MouseEventHandler(cell_MouseEnter); cell.MouseLeave -= cell_MouseLeave; cell.MouseLeave += new MouseEventHandler(cell_MouseLeave); } } } void cell_MouseLeave(object sender, MouseEventArgs e) { //Hide your popup } void cell_MouseEnter(object sender, MouseEventArgs e) { **// here i need to get the mouse position that is its x,y value based on that i can place my modal pop up in that postion. my pop is defined in xaml page here i will be assigning only its position where i need to place my modal pop up.** //

    Read the article

  • get html content of a page with Silverlight

    - by Yustme
    Hi, I'm trying to get the html content of a page using silverlight. Webresponse and request classes don't work in silverlight. I did some googling and I found something. This is what i tried: public partial class MainPage : UserControl { string result; WebClient client; public MainPage() { InitializeComponent(); this.result = string.Empty; this.client = new WebClient(); this.client.DownloadStringCompleted += ClientDownloadStringCompleted; } private void btn1_Click(object sender, RoutedEventArgs e) { string url = "http://www.nu.nl/feeds/rss/algemeen.rss"; this.client.DownloadStringAsync(new Uri(url, UriKind.Absolute)); if (this.result != string.Empty && this.result != null) { this.txbSummery.Text = this.result; } } private void ClientDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { this.result = e.Result; //handle the response. } } It gives me a runtime error after pressing the button: Microsoft JScript runtime error: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() at System.Net.DownloadStringCompletedEventArgs.get_Result() at JWTG.MainPage.ClientDownloadStringCompleted(Object sender, DownloadStringCompletedEventArgs e) at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e) at System.Net.WebClient.DownloadStringOperationCompleted(Object arg) I've tried numerous things but all failed. What am i missing? Or does anyone know how i could achieve this in a different way? Thanks in advance!

    Read the article

  • Get a button in itemscontrol and add eventhandler to its click event

    - by rockdale
    I have a custom control shows a customer info with an itemscontrol shows this customer's invoices. within the itemscontrol, I have button, in my code behind I want to wire the button's click event to my host window, but do now know how. //public event RoutedEventHandler ViewDetailClick; public static readonly RoutedEvent ButtonViewClickEvent = EventManager.RegisterRoutedEvent( "ButtonViewClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(custitem)); public event RoutedEventHandler ButtonViewClick { add { AddHandler(ButtonViewClickEvent, value); } remove {RemoveHandler(ButtonViewClickEvent, value);} } public override void OnApplyTemplate() { base.OnApplyTemplate(); this.lstInv = GetTemplateChild("lstInv") as ItemsControl; lstInv.ItemContainerGenerator.StatusChanged += new EventHandler(ItemContainerGenerator_StatusChanged); } private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e) { if (lstInv.ItemContainerGenerator.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated) { lstInv.ItemContainerGenerator.StatusChanged -= ItemContainerGenerator_StatusChanged; for (int i = 0; i < this.lstInv.Items.Count; i++) { ContentPresenter c = lstInv.ItemContainerGenerator.ContainerFromItem(lstInv.Items[i]) as ContentPresenter; DataTemplate dt = c.ContentTemplate; Grid grd = dt.LoadContent() as Grid; Button btnView = grd.FindName("btnView") as Button; if (btnView != null) { btnView.Click += new RoutedEventHandler(ButtonView_Click); //btnView.Click+= delegate(object senderObj, RoutedEventArgs eArg) //{ // if (this.ViewDetailClick != null) // { // this.ViewDetailClick(this, eArg); // } //}; } } private void ButtonView_Click(object sender, RoutedEventArgs e) { MessageBox.Show("clicked"); //e.RoutedEvent = ButtonViewClickEvent; //e.Source = sender; //RaiseEvent(e); } I succeed getting the btnView, then attach the click event, but the click event never get fired. Thanks in advance -rockdale

    Read the article

  • WPF RadioButton selected in UI, but seen by code as IsChecked == false

    - by Mike
    I have some radio buttons in a group box. I select the buttons randomly, and all works perfectly from a visual standpoint and also the event handler is called each time a new button is selected. Now I have a dependency property with a callback when the value changes. When in this callback procedure I read the IsChecked value of any button, the value is False, in spite the button is visually selected (they are all false at the same time, strange). The debugger also displays all buttons unchecked. Hu hu, I'm lacking ideas about the reason, after the basic verifications... <GroupBox> <StackPanel> <RadioButton x:Name="btNone" Content="Disconnected" IsChecked="True" Checked="OnSelChecked"/> <RadioButton x:Name="btManual" Content="Manual" Checked="OnSelChecked"/> </StackPanel> </GroupBox> Event handler: private void OnSelChecked(object sender, RoutedEventArgs e) { if (btManual.IsChecked == true) { // is called } } Dependency property: public static readonly DependencyProperty ManualProperty = DependencyProperty.Register("Manual", typeof(Position), typeof(SwitchBox), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender, new PropertyChangedCallback(OnManualChanged))); Dependency property callback: private static void OnManualChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { SwitchBox box = sender as SwitchBox; if (box.btManual.IsChecked == true) { // never true, why?? } }

    Read the article

  • Membership.Updateuser not really updating the database.

    - by Shimrod
    Hi everybody, I'm currently working on a membership system for my web application, which is based on forms authentication from the framework. I created some users with the integrated tool, and the login is perfectly working. But now what I want to do is to give administrator the capability to create, modify, delete users. So here is what I've got right now: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim muc As MembershipUserCollection = Membership.GetAllUsers() ComboBox1.DataSource = muc ComboBox1.DataValueField = "UserName" ComboBox1.DataTextField = "UserName" ComboBox1.DataBind() End Sub Protected Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ComboBox1.SelectedIndexChanged Dim userName As String = ComboBox1.SelectedValue Dim mu As MembershipUser = Membership.GetUser(userName) Dim userRoles As String() = Roles.GetRolesForUser(userName) tbComments.Text = mu.Comment tbEmail.Text = mu.Email lblUserName.Text = mu.UserName End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Dim userName As String = ComboBox1.SelectedValue Dim mu As MembershipUser = Membership.GetUser(userName) If Not mu Is Nothing Then Try mu.Comment = tbComments.Text Membership.UpdateUser(mu) mu.Email = tbEmail.Text Membership.UpdateUser(mu) mu.IsApproved = True Membership.UpdateUser(mu) mu = Nothing Catch ex As Exception Console.WriteLine(ex.ToString()) End Try End If DetailPanel.Visible = False End Sub The problem is that the record doesn't seem to be updated in the database. I made the multiple calls to Membership.UpdateUser after reading this blog entry, but it didn't change anything. A strange think I noticed while debugging, is that when I enter the Button1_Click method, Membership.GetUser(userName) returns me values from my precedent attempt ! I don't really understand what I'm missing. Does someone have a clue ? Thanks in advance !

    Read the article

  • Downloading a file from a PHP page in C#

    - by FoxyShadoww
    Okay, we have a PHP script that creates an download link from a file and we want to download that file via C#. This works fine with progress etc but when the PHP page gives an error the program downloads the error page and saves it as the requested file. Here is the code we have atm: PHP Code: <?php $path = 'upload/test.rar'; if (file_exists($path)) { $mm_type="application/octet-stream"; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: " . $mm_type); header("Content-Length: " .(string)(filesize($path)) ); header('Content-Disposition: attachment; filename="'.basename($path).'"'); header("Content-Transfer-Encoding: binary\n"); readfile($path); exit(); } else { print 'Sorry, we could not find requested download file.'; } ?> C# Code: private void btnDownload_Click(object sender, EventArgs e) { string url = "http://***.com/download.php"; WebClient client = new WebClient(); client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged); client.DownloadFileAsync(new Uri(url), @"c:\temp\test.rar"); } private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e) { progressBar.Value = e.ProgressPercentage; } void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { MessageBox.Show(print); }

    Read the article

  • Show NSSegmentedControl menu when segment clicked, despite having set action

    - by Justin Williams
    I have an NSSegmentedControl on my UI with 4 buttons. The control is connected to a method that will call different methods depending on which segment is clicked: - (IBAction)performActionFromClick:(id)sender { NSInteger selectedSegment = [sender selectedSegment]; NSInteger clickedSegmentTag = [[sender cell] tagForSegment:selectedSegment]; switch (clickedSegmentTag) { case 0: [self showNewEventWindow:nil]; break; case 1: [self showNewTaskWindow:nil]; break; case 2: [self toggleTaskSplitView:nil]; break; case 3: [self showGearMenu]; break; } } Segment 4 has has a menu attached to it in the awakeFromNib method. I'd like this menu to drop down when the user clicks the segment. At this point, it only will drop if the user clicks & holds down on the menu. From my research online this is because of the connected action. I'm presently working around it by using some code to get the origin point of the segment control and popping up the context menu using NSMenu's popUpContextMenu:withEvent:forView but this is pretty hacktastic and looks bad compared to the standard behavior of having the menu drop down below the segmented control cell. Is there a way I can have the menu drop down as it should after a single click rather than doing the hacky context menu thing?

    Read the article

  • How do I link one listview to another to create a football league table?

    - by Richard Nixon
    Hi I am creating a football system in windows forms c#. I have one listview where data is entered. I have 4 columns, 2 with team names linked to combo boxes and 2 with the scores linked to numericupdown controls. There are 3 buttons to add the results, Remove and clear. the code is below: private void addButton_Click(object sender, EventArgs e) { { ListViewItem item = new ListViewItem(comboBox1.SelectedItem.ToString()); item.SubItems.Add(numericUpDown1.Value.ToString()); item.SubItems.Add(numericUpDown2.Value.ToString()); item.SubItems.Add(comboBox2.SelectedItem.ToString()); listView1.Items.Add(item); } } private void clearButton_Click(object sender, EventArgs e) { listView1.Items.Clear(); } private void removeButton_Click(object sender, EventArgs e) { foreach (ListViewItem itemSelected in listView1.SelectedItems) { listView1.Items.Remove(itemSelected); } } I have another listview that i want to link the first one to. The second one is a usual english football league table and i want to use maths to add up the games played and the points etc. please help. cheers

    Read the article

< Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >