thanks for your help. this is a good fix for what i need to do. thanks for your input. :) .gonad
gonad
Posts
-
switch case from array -
switch case from arrayhow can i run a switch...case from all the elements inside an array? my example gives me an error saying 'a constant value is expected'. for example...(e.Node.Text shows the selected node from a treeview)
string[] cities = new string[3] {"atlanta","akron","cincinnati"}; for(int i = 1; i < cities.Length; i++) { switch(cities[i]) { case cities[i]: MessageBox.Show(e.Node.Text); break; } }
.gonad -
Don't display form iconthanks for the reply but it still shows on the form. when the child form is maximized inside the parent, the icon for the child form shows in the top left of the parent form (directly to the left of the 'file' menu). its the 'control' icon (restore,move,size,min,max,close). there is no way to remove this icon from what ive seen or tried. thanks, .gonad
-
Don't display form iconDoes anyone know how to hide the icon on a windows form? i have an MDI app and when i call a child form, an icon is displayed in the top left of the child. i dont want this for my child forms because it throws off the main Parent forms toolbar. any help would be appreciated. :) thanks, .gonad.
-
SQL Connectionyes! thank you very much for this. i haven't used the app.config before so this opens a lot of doors for me. thanks for the insight! gonad.
-
SQL ConnectionCan anyone tell me the best way to do this? Form1 has a listview that pulls data from a sql table and displays it in the listview. From Form1, how can i call a class that would make the SQL connection and run a query that would display my data to Form1? basically, i have a lot of Forms that individually make a SQL connection, but in the event of having to change SQL servers, i dont want to have to go into all 20 of these forms to change the SQL Connection string to point to a new server. Form1 -----
private void listfromDB() { string sqlString = "select * from table"; mySQLClass getSQLdata = new mySQLClass(); getSQLdata.SQLdata(sqlString); <...code to add data from query to listview...> }
Class1 ------public giveSQLdata(string _sqlString) { string sqlCon = "workstation id=LOCALHOST;packet size=4096;...etc"; SqlConnection sqlConnect = new SqlConnection(sqlCon); SqlCommand cmd = new SqlCommand(_sqlString, sqlConnect); sqlConnect.Open(); SqlDataReader dr = cmd.ExecuteReader(); return something... }
i'm new to this and need help...i freely admit this. :) thank you so much for your help. .gonad -
Open a Web BrowserThank you for your response! :) This will work perfectly for my situation. Have a blessed day!
-
Open a Web BrowserCan someone show me how i can open Internet Explorer by clicking on a button? I'm having a hard time finding out how to do this... Thank you for taking time with this lame-o question. :)
-
Context Menuthis article is very nice... Thanks for your help. :) .gonad.
-
Context Menui have a small app that sits in the Icon tray. how can i set the app's starting position to open at the bottom right, just above the clock? thanks for your help. :) .gonad.
-
RegistryI have a string value in the registry that i'm trying to read into my app. I need this value to be read as an integer so i can use it in a custom function.
RegistryKey rk = Registry.Users; rk = rk.OpenSubKey(@".DEFAULT\CustomForm", false); int result = calculate(rk.GetValue("GRN1"),2); public int calculate(int x, int y) { int result = x * y; return result; }
Therk.GetValue("GRN1")
returns an Object Type, but how can i get it to return an Integer type. I get an 'Invalid Cast' error when i try to cast from a different 'domain' (as msdn calls it)....int result = calculate((int)rk.GetValue("GRN1"),2);
so, how can i get an object value from the registry to convert to an integer? Thanks for your help .gonad. -
Closing an MDI Child Form[ append from previous post ] the only way i know how to do this is:
this.MDIChildren[0].Close();
this works for me since i only want one form open at a time, but i just want to know if there's another way to do this. Thanks! .gonad. -
Closing an MDI Child FormHow can i tell what forms are currently open and how do i close a specific form? My main form is an MDI parent with a toolbar. One button opens a form and when i click another button, i want to close the one that's open, but i'm having a hard time finding out what is open and how to close it. Thanks for your help. .gonad.
-
Setting Left Margin when printing...thank the Lord no one responded to this, because i feel really stupid. i just divided the margin by 2 to get .5". :-O
float leftMargin = ev.MarginBounds.Left / 2;
Thanks! :) .gonad. -
Setting Left Margin when printing...does anyone know how to set the left margin when printing a textfile? I have a form that prints to an Okidata 320 printer and the margin, by default, is set at 1". how can i set it to .5" on the Left margin only?
protected override void OnPrintPage(PrintPageEventArgs ev) { [other code here] float leftMargin = ev.MarginBounds.Left; [etc...] }
by the way, there is no way to set the margin on the okidata, nor can i move the form any farther to the right to fix this. it has to be done in the code. :) thanks. .gonad. -
Selected Checkbox...Hi. Thanks for your help. this worked exactly as you said, but i do have a queston. Can you explain what the
(CheckBox)sender
is specifying? also, can i use this for a textbox, or other controls, as well? for example,TextBox tb = (TextBox)sender;
I'm new at this stuff, can't you tell? Thanks again. .gonad. -
Selected Checkbox...Hi. i have a few checkboxes on my form and i want to show a simple messagebox when one of those checkboxes are checked. how can i do this dynamically? for instance, instead of writing an if statement per checkbox, like this:
if(checkbox1.checked = true) { MessageBox.Show("checked"); }
write it dynamically, like this: (the is the name of the selected checkbox)if(.checked = true) { MessageBox.Show("checked"); }
i know this is pretty easy for all you guru friends out there. :) Thanks, .gonad. -
what textboxes are on my form?:) you're right, i really appreciate your help on this and i have learned a LOT of stuff from everyone helping and i thank you. I got exactly what i needed and didn't even think about what you said regarding the textboxes on panels and tabs. i just thought it would show everything, but i was wrong. Thanks very much for everyone's help. :) .gonad.
-
what textboxes are on my form?i need to have all the names of the textboxes on my form put into an array. is there a way to dynamically set up an array of all the textboxes on my form? Thanks, .gonad.
-
simple question...sorry to be so lame with this question, but i'm still learning how this works. how can i get the input from a user in a textbox control on one form to display on another form?
//Form 1 private void data() { Mainform.sdgform sdg = new Mainform.sdgform(); MessageBox.Show(sdg.txtShipTo.Text); } //Form 2 public System.Windows.Forms.TextBox txtShipTo; public void textboxexample() //for example { this.txtShipTo.Text = "example data"; }
I have a whole form with a lot of textboxes that a user fills in and i need this data to write to a text file. the problem for me is that the toolbar button (on form 1) generates the 'write to textfile' code but it doesn't see the users input (from form 2). i know it's a lame-o question, but i'm still very new. Thanks for your help.