w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
The DataGridView is loading very slowly. How to optimise adding of rows in DataGridView?
Calling Rows.Add() is expensive. This is a quick-and-dirty change to get around that. private void GenerateRows(List<string[]> empList) { List<DataGridViewRow> rows = new List<DataGridViewRow>(); int len = empList.Count; for (int a = 0; a < len; a++) { string[] arr = empList[a]; //row 1 var row1 = new DataGridViewRow(); row1.Cells.Add(new DataGridViewTextBoxCell{Value = arr[0]}); /* CHANGED to add to List */ rows.Add(row1); //row 2 var row2 = new DataGridViewRow(); row2.Cells.Add(new DataGridViewTextBoxCell{Value = arr[1]}); /* CHANGED to add to List */ rows.Add(row2); //row3 var row3 = new DataGridViewRow(); row3.Cells.Add(new DataGridVi

Categories : C#

How do I add various numbers of datagridview at runtime?
for x = 1 to number_of_items dim dgv_x As New DataGridView ... next If you mean replace _x with your value and then access your controls like this dgv_1, dgv_2, unfortunately No, this is not possible. But you can instead declare a List(Of DataGridview), and add each DataGridView to the list: Public Function GetDataGridView(ByVal number As Integer) As List(Of DataGridView) Dim myDgvCollection As New List(Of DataGridView) If number > 0 Then For x As Integer = 1 To number Dim dgv As New DataGridView '... myDgvCollection.Add(dgv) Next End If Return myDgvCollection End Function Then you access you can access them by their index, like this: Dim dgv As DataGridView = myDgvCollection(0) Don't forget that index a

Categories : Vb.Net

Trouble using datagrid (or datagridview) in wpf or winform
if Grid SelectionUnit is set to "FullRow" then use below code. ((DataRowView)dgGroup.SelectedItem).Row -> This will give you current data row ((DataRowView)dgGroup.SelectedItem).Row.ItemArray[0] -> This will give first column value ((DataRowView)dgGroup.SelectedItem).Row.ItemArray[1] -> This will give second column value if Grid SelectionUnit is set to "Cell" then use below code. (DataRowView)dgGroup.SelectedCells[0].Item -> This will give you current data row ((DataRowView)dgGroup.SelectedCells[0].Item).Row.ItemArray[0] -> This will give first column value Adding some more code based on your comment to loop through sections. // Find index of selected row which would be group/block row. Add 1 to find first section row in that block/group. var in

Categories : C#

Adding Combobox to DataGridView Headers
at your code, comboBoxHeaderCell.Location = dataGridView.GetCellDisplayRectangle(i, -1, true).Location; will always return 0,0, and therefor you put your ComboBox at location 0,0 in the DataGridView, and that's why we see this you can use dataGridView1[i,0].size for the size needed i'm looking for location i couldn't find that, but what you can do is using the dataGridView1.Width - dataGridView1[1,0].Size.Width you can use the width, and remove the size of all the headers width, and then add them one by one. int xPos = dataGridView1.Width; for (int i = 0; i < 4; i++) { xPos -= dataGridView1[i, 0].Size.Width; } ... comboBoxHeaderCell.Size = dataGridView.Columns[0].HeaderCell.Size; comboBoxHeaderCell.Location = new Point(xPos, 0); xPos += comboBoxHeaderCell.Size.Width;

Categories : C#

Adding rows to a databound datagridview
Try using BindingSource like Dim m_Bs as new BindingSource m_Bs.DataSource = DataSet1.Tables("TableName") DataGridView1.Datasource = m_Bs And enable adding row on DataGridView1 Any changes From the Datagridview will reflect on the Dataset.

Categories : Vb.Net

Adding ComboBoxes to a DataGridView programatically
I ended up adding the Rows to the DataGridView like this: private void SetDataSource(IEnumerable<Object> assignedObjects, List<Container> subContainersAssociatedWithSystem) { _objectDataGridView.Rows.Clear(); foreach (var assignedObject in assignedObjects) { var newRowIndex = _objectDataGridView.Rows.Add(); var row = _objectDataGridView.Rows[newRowIndex]; row.Cells["Id"].Value = assignedObject.Id; row.Cells["Name"].Value = assignedObject.Name; var containerColumn = (DataGridViewComboBoxCell)row.Cells["Container"]; containerColumn.DataSource = subContainersAssociatedWithSystem; containerColumn.Value = assignedObject.Container.Id; var objectTypeColumn = (DataGridViewComboBoxCe

Categories : C#

Dynamically adding columns to DataGridView as it gets expanded
u can use the Resize Event of the Datagridview and Add and Remove (or set visibilty) of all rows that are unwanted. I guess your columns have a given size and are not sized automatically. In that case u can: int columnsToShow = (int)(dataGridView.Size.Width / columnWidth); now add enough rows to match the wanted number / remove all rows that are too much or set visibility

Categories : C#

Adding Different DataGridView Cell Types to a Column
Have you looked at these: Mixing cell types in a DataGridViewColumn DataGridview cells of one column can't have different type http://social.msdn.microsoft.com/Forums/windows/en-US/148b232b-ce8c-4c49-b35d-50d8a5c448d1/different-cell-types-in-a-datagridview-column Following from the MSDN article... There are two ways to do this: Cast a DataGridViewCell to a certain cell type that exists. For example, convert a DataGridViewTextBoxCell to DataGridViewComboBoxCell type. Create a control and add it into the controls collection of DataGridView, set its location and size to fit the cell that to be host. Here's some sample code which illustrates these tricks: private void Form5_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("name"); for

Categories : C#

Display record in datagridview after adding to database
The code you've shown will successfully add a record to the database, but it doesn't make any attempt to refresh anything in the UI. Where is the code which binds the grid to records in the database? That code needs to be run again after this code runs. I'm assuming that code exists in some sort of initializer for the form. Perhaps some sort of load event? You'll want to move that grid-binding code into its own function and call it from both the load event and at the end of this click event, probably right after the line where you commit the transaction.

Categories : SQL

Adding a single row with a single column of one datagridview into another datagridview of multiple column
Hope this helps: private void dgv1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 3) { int newRow = dgv2.Rows.Add(); dgv2.Rows[newRow].Cells[0].Value = dgv1.Rows[e.RowIndex].Cells["Stringtext"].Value; } } This should take the value from the StringText cell and place it in the first column of a newly created row in the second grid when the button in cell 4 is clicked in the first grid. EDIT: private void dgv1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 3) { dgv1.Rows[e.RowIndex].Cells["Stringtext"].Value = dgv2.Rows[{y}].Cells[0].Value; } } This one should set the value of the cell "StringText"(which can be changed to whatever yo

Categories : C#

Adding image icon to Winform datagridview margin
Try this code, not complete but would be good for you to get started, this will add the same image to all the cells, click on the image will show some message (you can customize this): //CellPainting event handler to draw image on cell private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.ColumnIndex > -1 && e.RowIndex > -1 && e.Value != null) { e.Handled = true; e.PaintBackground(e.CellBounds, true); e.Graphics.DrawImage(Properties.Resources.YourIMAGE, new Rectangle(e.CellBounds.Left, e.CellBounds.Top + 2, e.CellBounds.Height - 4, e.CellBounds.Height - 4)); StringFormat sf = new StringFormat() { LineAlignment = StringAlignment.Center };

Categories : C#

Adding DataRow[] data to each column in an unbound DataGridView?
Before you access to DataGridView1.Rows[i].Cells[j], you need to make sure DataGridView1.Rows[i] exists. If no, you need to add it to the DataGridViewRowCollection. You can find a lot of sample on on this page.

Categories : C#

Linq to XML C# Adding parent to child nodes in datagridview
With LINQ2XML fetching the data could be done like this (the variable xmlSource holds the xml code): var xml = XElement.Parse(xmlSource); var jobs = xml.Descendants("Job").ToList(); var person = xml.Element("Person").Elements("Name").First().Value; foreach (var job in jobs) { Console.WriteLine(string.Format("{0} - {1}", person, job.Element("Title").Value)); } For the DataGridView: add new row for every Person and new Cell for every job title / company or create a simple datasource, fill it with the data and give it to the DataGridView object. Create a data object class Person: public class Person { public string Name { get; set; } public string Title { get; set; } public string Company { get; set; } } Create a List of Person's, fill it with the data from the XML and

Categories : Xml

Adding "hidden (or meta)" column to DataTable that will not be displayed in the bound DataGridView
Change the Visible property of your DataGridViewColumn. From msdn: // Hide a band of cells. private void Button6_Click(object sender, System.EventArgs e) { DataGridViewBand band = dataGridView.Rows[3]; band.Visible = false; }

Categories : C#

Adding dex to Android classpath at runtime
Try code in https://gist.github.com/nickcaballero/7045993 This method kind of appends your newly created DexClassLoader to the existing one. Note it uses reflection so it may not work for all Android version. At least it works on my SDK19.

Categories : Java

Adding words to a 'Dictionary' at runtime
Assuming you have a TextBox for a word and another TextBox(multiline) for it's meanings. WordMDictionary(txtWord.Text) = txtMeanings.Lines So one line is one meaning.

Categories : Vb.Net

Adding images to application at runtime
Nothing you can do about the speed of retrieving from Azure (short of selecting a cloud service based on performance but Azure is probably as good as any) and assuming your SQL code is efficient, the Q becomes where and how to store/retrieve and how to keep the UI responsive as you download and install the images. I would store in private storage since it's generally much higher performance than SDCard and has fewer unknowns. You should also scale down the bigger images to the minimum resolution that still works on your highest resolution target devices for your UI. Remember that a bitmap in memory takes x*y*4 bytes by default which is about 2.6MB each in your case. Android: high quality image resizing / scaling I assume that the main UI you have shown is a ListView of some sort so

Categories : Android

Adding menu items during runtime in C#
You want this List<MenuItem> inputDevice = new List<MenuItem>(); MenuItem myMenuItemInputDevices = new MenuItem("&Input Devices"); sgFileMenu.MenuItems.Add(myMenuItemInputDevice); for (int i = 0; i < DeviceCount; i++) { inputDeviceMenu.Add(new MenuItem(inputName[i])); inputDeviceMenu[i].Click += new System.EventHandler(this.myMenuItemInputDeviceClick); myMenuItemInputDevices.MenuItems.Add(inputDeviceMenu[i]); myMenuItemInputDevices.Click += new System.EventHandler(this.myMenuItemInputDeviceClick); } EDIT: It is pretty obvious that the Menu Items that you are trying to add does not have any Click event method hooked up. inputDeviceMenu.Add(new MenuItem(inputName[i])); You are just adding them.

Categories : C#

Trouble with adding to HashMap using arguments
public void addServer(String x, int y, int z){ ServerDetails details new ServerDetails(y,z); serverList.put(x, details); } Are you perhaps forgetting an equals sign in the second line?

Categories : Java

Trouble Adding a new field to a Model
The problem is because you are passing IEnumerable model. In this case you should enumerate through all you model items and pass them into HtmlHelper methods. And in this case I recommend you to pass List in your view like this: @model List<FTv2.Models.UserProfile> @using (Html.BeginForm()) { for (int i = 0; i < Model.Count; i++) { <fieldset> <legend>Edit</legend> <div class="editor-label"> @Html.LabelFor(model => model[i].UserInput) </div> <div class="editor-field"> @Html.EditorFor(model => model[i].UserInput) @Html.ValidationMessageFor(model => model[i].UserInput) </div> <p> <input type="submit" value="Save" /&

Categories : C#

Trouble adding double the divs i already have
Use setInterval rather than setTimeout. setInterval is used for events that happen repeatedly based on the time you set, while setTimeout happens once. jsfiddle

Categories : Jquery

Waf, trouble adding manual dependencies
It depends on how you want the target to be produced from the dependencies. In the simplest case, you just use a build-rule with sources and a target: def build(bld): bld( rule = 'cat ${SRC[0].abspath()} > ${TGT}', source = ['hello.txt', 'there.txt'], target = 'out.txt' ) As you can see, out.txt will be produced by cat:ing hello.txt to it and both hello.txt and there.txt will be seen as the targets dependencies. Here I have hardcoded the dependencies in the wscript, but you would of course call your program that generates the dependencies list as use that.

Categories : Python

Trouble with adding chars to char*[]
You could use: char *spots[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; char *player1 = "X"; char *player2 = "O"; and then assign: spots[i] = player1; The types are consistent: spots is an array of char *, and assigning a char * string to one entry in the array makes sense — and it is a pointer to a null-terminated string that is assigned, the same as the other values in spots. You might want to consider: char *player[] = { "?", "X", "O" }; Then you can use: spots[i] = player[j]; The "?" allows you to use the encodings 1 and 2 for the players, of course. With your code, you are assigning the address of a single character, not a string, to the spot, and the printing code then reads until it finds a null, leading to confusion.

Categories : C++

Having trouble adding jquery to charisma
I meet the same problem as you do. My solution is like this: find the line " $("input:checkbox,input:radio, input:file").not('[data-no-uniform="true"],#uniform-is-ajax').uniform();" then,remove the input:checkbox, then the checkbox in your project will not display in the charisma way.Now you can use $(this).prop("checked","checked"); to make the checkbox change.

Categories : Jquery

Trouble adding checkboxes to HTML div using JS
you are using the submit type input. when you click on submit button page reload will occur and you cant see the result of your javascript code use a button instead <input type="button" value="Add New Task" onClick="addTask()" id = "taskAdder">

Categories : Javascript

Trouble when adding actionListener() to a JPanel
JPanel doesn't have the capabilities to raise ActionEvents, thus it does not have the method addActionListener. Instead, you probably want to use a MouseListener instead Check out How to write mouse listeners for more details...

Categories : Java

Does terracotta support adding a node during runtime?
I work for Terracotta as a Software Engineer. At this point, you can't add a node to a Terracotta Cluster dynamically. You'll need to shut down the cluster, add the new servers to your tc-config file and then restart the cluster. As far as your understanding of the architecture goes, it's correct when seen from a 30,000 feet level. For sessions replication, I recommend that you look at our Sessions product. http://terracotta.org/documentation/4.0/web-sessions

Categories : Java

Adding UIView on top of all views dynamically during runtime?
An easier way would be add the menu view to the controller's view. You will have some benefits: It will handle rotation correctly You do not mess with window Taking a look to your code, I should suppose that you are using it inside a view controller, thus you do not need to call [window makeKeyAndVisible]. Also, you are not showing which window you are talking about. Are you creating it? are you using the one of your root view controller?

Categories : Iphone

Adding controls at runtime in from derived class in MFC
Declare a member variable CButton m_ctrl_chk, override DialodDervied::OnCreate() and add code like int DialodDervied::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialogEx::OnCreate(lpCreateStruct) == -1) return -1; m_ctrl_chk.Create(_T("Checkmate"), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, CRect(5, 5, 100, 20), this, 1234); // the 1234 value is the ID of the control return 0; } Use similar classes (CEdit, CStatic, CButton, ...) to create other type of controls in the same way.

Categories : C++

Trouble with adding default subfolder with htacess
Try adding a slash after the ^: RewriteCond %{HTTP_HOST} (.*)example.com$ RewriteCond %{REQUEST_URI} !^/(pl|no|en) [NC] RewriteRule (.*) http://www.example.com/en/ [R=301,L] The REQUEST_URI usually begins with a /

Categories : Htaccess

Having trouble adding a JComboBox to JXTable Cell
I have solved the problem I mistakenly disabled cell editing. All I did was to remove the code below: @Override public boolean isCellEditable(int rowIndex, int colIndex) { return false; //Disallow the editing of any cell

Categories : Java

jQuery Adding and Removing Rows Trouble
Alright, I think I found your problem. You are trying to call $(table).querySelectorAll('tr'). .querySelectorAll is a javascript function that you are using with a JQuery selector. This is where your removeRow() function bombs. Try commenting that line out. Then, you will need to find a new way to select the last row, which can easily be done with this: $(table).find('tr:last').remove(); Final form: function removeRow(){ //var items = $(table).querySelectorAll('tr'); if (rowCount > 1) { //$(table).remove(items[rowCount - 1]); $(table).find('tr:last').remove(); rowCount -= 1; } else { alert('CANNOT DELETE LAST ROW'); } } If you want this to work in IE8 and older, you can use this JQuery since you have the number of rows: $(ta

Categories : Javascript

Android runtime error when adding imageview to view
I think the problem is that you're declaring baseBoard as a member variable but masking it with a local variable named baseBoard in your onCreate method (or wherever the first blob of code you posted came from). Here's what I think is going on: public class MyActivity extends Activity { RelativeLayout baseBoard; protected void onCreate(Bundle savedInstanceState) { RelativeLayout baseBoard = new RelativeLayout(this); } } In this code, you declare two different variables called "baseBoard". The variable that is declared in your onCreate masks the member variable "baseBoard" and prevents it from ever getting set. That's why you hit a null pointer exception in your click handler.

Categories : Java

Runtime 9 Error when adding worksheets from a list of files
Morning, The error occurs when trying to add the 3rd worksheet to accept the copied data. The error comes up with "subscript out of range" runtime error 9 Does the fact that it works twice, when debugging it opens the data workbook, identifies the data, selects the range. It will just not add the new worksheet to paste the data. Could a way round this be for the Filelist variable count the number of files in the list then add the correct number is sheets to the new workbook then just use a loop to copy and paste the data across the sheets.

Categories : Excel

Trouble adding horizontal scroll on dynamic table
Change $('#' + tableName + 'Table').css('overflow-x', 'scroll'); To $('#' + tableName + 'Table').parent().css('overflow-x', 'scroll'); The parent element is the one that needs the overflow-x property. Also you don't need javascript for this functionality. You can just set overflow-x: auto; to the parent element, and it will add a scrollbar automatically if its contents are too wide.

Categories : Javascript

Trouble adding user defined function in Doctrine 2
It turns out that after modifying correctly my bootstrap.php file, I was still unable to make the function work. After some fiddling, I found out that while my query still doesn't work, the function do work using this form : $results = $s->select("GroupConcat(t.name) As Name")->from("Type","t")->getQuery()->getResult(); So, after all, my problem resides in the DQL syntax using GroupConcat.

Categories : PHP

C# WinForms, Adding a usercontrol Dynamically during runtime and controls are invisible?
It seems that you have called SuspendLayout() without telling the panel to ResumeLayout() pnl_ContactDetails.SuspendLayout(); for(int i = 3; i < details.Count; i++) { TextPrompt txtbox = new TextPrompt(details[i]); //Textbox to be added MessageBox.Show(details[i].value); txtbox.Name = details[i].name; //Sets properties txtbox.Location = new Point(25, y); txtbox.Size = new System.Drawing.Size(345, 45); txtbox.TextValueChanged += new EventHandler(txtbox_TextChanged); /* txtbox.Show(); */ // Leave this call out in favor of: txtbox.Visible = true; this.pnl_ContactDetails.Controls.Add(txtbox); txtbox = (TextPrompt)this.pnl_ContactDetails.Controls[i - 3]; //Checks to make sure controls are on form. MessageBox.Show(txtbox.ContactDetails.name);

Categories : C#

I'm having trouble adding a shapefile to my ggmap due to differing geographic units
Here You have an answer: library(ggmap) library(maptools) shapefile <- readShapeSpatial('MunicipalBoundaries_polys.shp', proj4string = CRS("+proj=lcc +lat_1=34.33333333333334 +lat_2=36.16666666666666 +lat_0=33.75 +lon_0=-79 +x_0=609601.2199999997 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs")) shp <- spTransform(shapefile, CRS("+proj=longlat +datum=WGS84")) data <- fortify(shp) nc <- get_map("North Carolina", zoom = 6, maptype = 'terrain') ncmap <- ggmap(nc, extent = "device") ncmap + geom_polygon(aes(x = long, y = lat, group = group), data = data, colour = 'grey', fill = 'black', alpha = .4, size = .1) The coordinates needs to be transform to longlat projection and it's working.

Categories : R

PHP - Trouble adding multiple drop down menu options to MySQL
As Bart said mysql_real_escape_string works with strings, not with arrays. The reason your $_POST['game'] is an array is because you have it named game[]. You can try with one value if you change the name to game. Although we want the code to work with multiple choices. You can change the PHP code like this: <?php if(isset($_POST['submit'])) { $query=mysql_connect('localhost','root',''); mysql_select_db("freeze",$query); $choice = array(); foreach($_POST['game'] as $game) { $choice[]=mysql_real_escape_string($game); } $choice1=implode(',',$choice); mysql_query("insert into tb values('','$choice1')"); } ?> By the way, can you tell us what is your database structure? It seems you are making a big mistake with saving all the values the user picked

Categories : PHP

Adding an event handler to a specific children within a DOM tree that is created on runtime
You can try doing - $("#progData").find("img").on("click", function(e){/*do sth in here*/}); If the HTML is already loaded before the code is hit. OR You could try adding a class to the dynamic content and then bind on its click event such as HTML - <tr><td><img class="jMyImage" src="bla.png"></td></tr> Javascript - $(".jMyImage").on("click", function(e){/*do sth in here*/});

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.