DBGrid - how to show the differnce between a column value in two adjacent rows as another column?
Tag : mysql , By : user171555
Date : March 29 2020, 07:55 AM
help you fix your problem Let's say I record my car's latitude & longitude every minute or so, adding a row to a table each time. , You can do it either way:
|
How to use GridBagLayout to make a JLabel 1 column wide and then a JTextField 2 columns wide (for a total width 3 column
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Using GridBagLayout columnWidths you can manually adjust the widths and then set the GridBagConstraints fill to GridBagConstraints.HORIZONTAL : import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import javax.swing.JTextField;
import java.awt.Insets;
public class Example extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Example frame = new Example();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Example() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
GridBagLayout gbl_contentPane = new GridBagLayout();
gbl_contentPane.columnWidths = new int[] {100, 0};
gbl_contentPane.rowHeights = new int[]{0, 0, 0};
gbl_contentPane.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
gbl_contentPane.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
contentPane.setLayout(gbl_contentPane);
JLabel lblNewLabel = new JLabel("jlabel");
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
gbc_lblNewLabel.gridx = 0;
gbc_lblNewLabel.gridy = 0;
contentPane.add(lblNewLabel, gbc_lblNewLabel);
textField = new JTextField();
GridBagConstraints gbc_textField = new GridBagConstraints();
gbc_textField.insets = new Insets(0, 0, 5, 0);
gbc_textField.fill = GridBagConstraints.HORIZONTAL;
gbc_textField.gridx = 1;
gbc_textField.gridy = 0;
contentPane.add(textField, gbc_textField);
textField.setColumns(10);
JLabel lblNewLabel_1 = new JLabel("jlabel2");
GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
gbc_lblNewLabel_1.anchor = GridBagConstraints.WEST;
gbc_lblNewLabel_1.insets = new Insets(0, 0, 0, 5);
gbc_lblNewLabel_1.gridx = 0;
gbc_lblNewLabel_1.gridy = 1;
contentPane.add(lblNewLabel_1, gbc_lblNewLabel_1);
textField_1 = new JTextField();
GridBagConstraints gbc_textField_1 = new GridBagConstraints();
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
gbc_textField_1.gridx = 1;
gbc_textField_1.gridy = 1;
contentPane.add(textField_1, gbc_textField_1);
textField_1.setColumns(10);
}
}
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import net.miginfocom.swing.MigLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class MigLayoutExample extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MigLayoutExample frame = new MigLayoutExample();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public MigLayoutExample() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new MigLayout("", "[grow 33][grow 66]", "[][]"));
JLabel lblNewLabel = new JLabel("New label");
contentPane.add(lblNewLabel, "cell 0 0");
textField = new JTextField();
contentPane.add(textField, "cell 1 0,growx");
textField.setColumns(10);
JLabel lblNewLabel_1 = new JLabel("New label");
contentPane.add(lblNewLabel_1, "cell 0 1");
textField_1 = new JTextField();
contentPane.add(textField_1, "cell 1 1,growx");
textField_1.setColumns(10);
}
}
|
Delphi select line in a dbgrid and show other lines in other dbgrid
Tag : delphi , By : Harry Truman
Date : March 29 2020, 07:55 AM
I hope this helps you . Use a separate query for your customer table, with SQL something like this (replace CustQuery with the name of your own ADOQuery component, and the table and column names for your actual table information, of course): CustQuery.SQL.Text := 'SELECT c.customer_name, c.customer_address' + #13 +
'FROM customer c' + #13 +
'WHERE c.provider_name = :provider';
procedure TForm1.ProviderQueryAfterScroll(DataSet: TDataSet);
begin
CustQuery.DisableControls;
try
CustQuery.Close;
CustQuery.Paramseters.ParamByName('provider').Value :=
ProviderQuery.FieldByname('Provider_Name').Value;
CustQuery.Open;
finally
CustQuery.EnableControls;
end;
CustQuery.Open;
end;
|
Have the 8-column-wide div all the 12 columns if the 4-column-wide div is not exist with Twitter Bootstrap
Tag : php , By : PsyberMonkey
Date : March 29 2020, 07:55 AM
Hope this helps What I want is, if the the 4-column-wide section is not exist, means it's disabled server-side, the 8-column-wide section will have all the 12 columns. , The solution that's coming from my mind: $var = true; // sometimes false
<div class="row">
<?php if ($var) echo '<div class="col-md-4">.col-md-4</div>'; ?>
<div class="col-md-<?php
if ($var) :
echo 8;
else :
echo 12;
endif;
?>">.col-md-8</div>
</div>
|
Adding a search that searches data in a DBGrid and temporarily changes what that DBGrid displays- Delphi
Tag : mysql , By : pacorro2000
Date : March 29 2020, 07:55 AM
This might help you If you're dealing with a small number of rows returned by your SQL SELECT, you can use TDataSet.Filter and TDataSet.Filtered. You can get the input from anywhere you'd like, such as a plain old TEdit. As you've posted no details (such as the DB controls you're using, the version of Delphi, any code that gives variable names, or anything else), here's a very generic sample that may help. I'm calling the query attached to the DBGrid Qry, because have no idea what else to call it based on what you've posted. FilterRecordsButton and ClearFilterButton are TButtons, and SearchEdit is a TEdit. Feel free to use any control you want to toggle the filter or get the input from the user. procedure TForm1.FilterRecordsButtonClick(Sender: TObject);
begin
if SearchEdit.Text <> '' then
begin
{
The brackets around the column name are required because you've got
spaces in the name; they're also needed if your column name is a
reserved word. QuotedStr puts the necessary quote characters around
the value.
}
Qry.Filter := '[Customer Name] = ' + QuotedStr(SearchEdit.Text);
Qry.Filtered := True;
Qry.First;
FilterRecordsButton.Enabled := False;
ClearFilterButton.Enabled := True;
end;
end;
procedure TForm1.ClearFilterButtonClick(Sender: TObject);
begin
Qry.Filtered := False;
Qry.Filter := '';
Qry.First;
ClearFilterButton.Enabled := False;
FilterRecordsButton.Enabled := True;
end;
|