programmatically-created

How can I create a button programmatically in C# window app?

倖福魔咒の 提交于 2021-02-08 12:01:19
问题 I know that it easy to just drag and drop a button, however a lecturer insists on creating buttons programmatically. In the Form1_Load method what code should I write to create a simple button? private void Form1_Load(object sender, System.EventArgs e) { } So that on Load the button would show? 回答1: As you said it is Winforms, you can do the following... First create a new Button object. Button newButton = new Button(); Then add it to the form inside that function using: this.Controls.Add

Swift programmatically-added constraints dont work

不羁岁月 提交于 2020-04-30 06:46:07
问题 I have a view inside a scrollview: Now I want to add the child views to that view programmatically. Thats my code to do that: Child view (works) //Adds header to the view again because it was removed in the clear() method //Header is just a label lv.addSubview(header) header.leadingAnchor.constraint(equalTo: header.superview!.leadingAnchor).isActive = true header.topAnchor.constraint(equalTo: header.superview!.topAnchor, constant: 2).isActive = true header.widthAnchor.constraint(equalTo:

How to change layout constraints programmatically on display rotation

余生颓废 提交于 2020-01-25 15:52:21
问题 For an app (iOS 7 compatible) I need to have the possibility for totally different layouts in landscape and portrait mode. I see the only way in setting the constraints programmatically and change them on rotation. So I set my interface using IB and then set the constraints programmatically. I saw somewhere the approach to remove first all constraints, then create and add new constraints and then set the update flag for constraints on the parent view. I want the elements just to be full width

How to change layout constraints programmatically on display rotation

对着背影说爱祢 提交于 2020-01-25 15:50:49
问题 For an app (iOS 7 compatible) I need to have the possibility for totally different layouts in landscape and portrait mode. I see the only way in setting the constraints programmatically and change them on rotation. So I set my interface using IB and then set the constraints programmatically. I saw somewhere the approach to remove first all constraints, then create and add new constraints and then set the update flag for constraints on the parent view. I want the elements just to be full width

Java forced thread dump programmatically - like “jstack -F -l <PID>”

天大地大妈咪最大 提交于 2020-01-02 17:24:29
问题 I am trying to do a forced java thread dump programmatically, just like the command jstack -F -l <PID> would do it. My best attempt: I created a subclass from sun.jvm.hotspot.tools.JStack overwriting run() with the following code analogous to sun.jvm.hotspot.tools.JStack.run() but in the last line calling start(printstream) instead of start() : StackTrace stacktrace = new StackTrace(mixedMode, concurrentLocks); try { Class<?> stacktraceTool = stacktrace.getClass().getSuperclass(); Method

TextView programmatically Android

╄→гoц情女王★ 提交于 2020-01-01 11:59:28
问题 I have some problems creating a textView programmatically. I don't really know how to solve it. The problems are : -The margin, I don't want my TextView stuck to each other. -The text is not centered in the drawable like in the title -I want the messages of Nickname user aligned to the right and the messages of Nick aligned to the left. For this I have these two functions : private void appendSenderText(String message) { TextView msg = new TextView(ChatActivity.this); msg

Swift: Programmatically transitioning from 1 view to another via a TabBar and Navigation Controller

北战南征 提交于 2019-12-24 05:47:11
问题 The user logs in and lands on viewNumOne, they fill out their name and address and get to see viewNumTwo and viewNumThree. They now logout. When they log back in I want them to go straight to viewColorBlue (this is where I am having the problem). (Login Screen) View Controller with login fields. Once logged in they go to the rootVC which is a TabBar and they land on the first tab which is viewNumOne (this works fine) (Root) TabBar: (First Tab - tabBar[0]) viewNumNavController > viewNumOne

set UIButton's buttonType programmatically [duplicate]

廉价感情. 提交于 2019-12-22 01:24:19
问题 This question already has answers here : How do I create a basic UIButton programmatically? (34 answers) Closed 6 years ago . I have a UIButton which I've added in IB, however the view behind this button changes color and I need to switch the button's type between InfoDark and InfoLight . Bizarrely though, buttonType property is read only. So how can i switch between light and dark info buttons? 回答1: There's no way to change the .buttonType once it's set. You can prepare two buttons, and hide

How do I programmatically call authenticate from within a servlet like j_security_check would do

梦想与她 提交于 2019-12-21 22:01:50
问题 We have the web based form login authentication with j_securtiy_check working. We'd like to change it by programmatic login authentication. What is the proper way of having a servlet authenticate a user name and password passed to it? The servlet is obviously unprotected. We have been experimenting with this server.xml Realm: <Realm className="org.apache.catalina.realm.DataSourceRealm" dataSourceName="UserDatabase" userTable="app_user" userNameCol="login_name" userCredCol="password_value"

Swift 3 Create UILabel programmatically and add NSLayoutConstraints

佐手、 提交于 2019-12-18 13:24:10
问题 Hello I am trying to create a label programmatically and add NSLayoutConstraints so that it is centered in the superview regardless of screen size and orientation etc. I have looked but just can't find an example to follow. Here is what I have: let codedLabel:UILabel = UILabel() codedLabel.frame = CGRect(x: 100, y: 100, width: 200, height: 200) codedLabel.textAlignment = .center codedLabel.text = alertText codedLabel.numberOfLines=1 codedLabel.textColor=UIColor.red codedLabel.font=UIFont