Can't see dropdown items in Datagridviewcomboboxcell - vb.net

I have created Datagridviewcomboboxcells as follows, each of which have 2-3 items.
I'm able to see the Datagridviewcomboboxcells with the appropriate values inside the comboboxcell, but I'm not able to see the dropdown list when i click on the comboboxcell.
Should I write a separate event handler to display the dropdown list ? Does it not dropdown by default ?
Dim Dgv2cb_ColdStart As New DataGridViewComboBoxCell
Dgv2cb_ColdStart.Items.Add("C:\pd_DelAll.pl")
Dgv2cb_ColdStart.Items.Add("No Cold Start")
dgv2.Rows.Add("ColdStart")
dgv2.Rows(rowIndex).Cells(1) = Dgv2cb_ColdStart
If temp_profile.ColdStart = "" Then
dgv2.Rows(rowIndex).Cells(1).Value = Dgv2cb_ColdStart.Items(1)
Else
dgv2.Rows(rowIndex).Cells(1).Value = Dgv2cb_ColdStart.Items(0)
End If
Surprising thing is the same code on another backup of the project works, but that is an older version that i can't use now.
I'm not able to reproduce the error, as to what is causing the dropdown not to occur.

Related

How to clear Kendo grid rows without invoking databound method?

I have a grid with databound method which shows the message 'No Data Found for the search' in case no data gets retrieved after performing search. Now i have added a radio buttons which when clicked needs to clear the old data from the grid. The issue is i am using the code $(grid).data("kendoGrid").dataSource.data([]); which does clear the grid but it also shows 'No Data Found for the search' message. Since user didn't perform any search but only changed the radio button it doesn't seem right to display that message in the grid. So, i was wondering if there was a way to clear the grid without invoking the databound method.
Grid code that calls databound function:
#(Html.Kendo().Grid<SearchModel>()
.Events(events => events.DataBound("gridDataBound"))
Databound code:
function gridDataBound(e) {
var grid = e.sender;
var gridName = "#" + grid.table.context.id;
if (grid.dataSource.total() == 0) {
var colCount = grid.columns.length;
$(e.sender.wrapper)
.find('tbody')
.append('<tr class="kendo-data-row"><td colspan="' + colCount + '" class="no-data">No Records Meet Your Search Criteria.</td></tr>');
}
$(gridName).find(".k-pager-wrap").hide();
};
Thanks.
As far as i know there is no way of doing this without putting an e.preventDefault() in the dataBound function. What you can do is maybe make a boolean that your dataBound function uses to check whether it should display the message or not?

Accessing RadListBox Items in Code-Behind

I have the following RadListBox:
<telerik:RadListBox ID="AttachmentsRadListBox" CheckBoxes ="true" runat="server" />
It is located in a RadWindow, therefore I am populating it through the following code which is only called when RadWidnow becomes visible:
AttachmentsRadListBox.DataSource = AttachDT
AttachmentsRadListBox.DataTextField = "DocumentPath"
AttachmentsRadListBox.DataValueField = "DocumentID"
AttachmentsRadListBox.DataBind()
For Each item As RadListBoxItem In AttachmentsRadListBox.Items
item.Checked = True
Next
So far so good, the RadListBox is populated and all the items are checked.
Now, there is a Save button on the RadWindow when pressed before closing the window I am trying to read the checked items in the AttachmentsRadListBox (Since the user might have changed the status of the checked items). But every effort on reading the items has failed, for example on the Save button click I have the following:
Dim test As Integer = AttachmentsRadListBox.Items.Count // THIS IS ZERO
For Each item As RadListBoxItem In AttachmentsRadListBox.Items // THERE ARE NO ITEMS
If Not item.Checked Then
Dim DocumentIDToDelete As Integer = item.Value
End If
Next
Why is that the last piece of code does not behave as I hope? The AttachmentsRadListBox is not being bounded again through the postback. The only time that it is bounded is when the RadWindow appears. Then the Save button on the RadWindow obviously creates a postback but I don't understand why AttachmentsRadListBox contains no item at that point.
Since you create the AttachmentsRadListBox dynamically, do you recreate it on subsequent postbacks? It is, in the end, a server control, so you need to make sure it is recreated, because otherwise ASP will destroy it upon a subsequent postback.
To see how you can access controls in the ContentTemplate of a RadWindow you can also examine this article: http://www.telerik.com/help/aspnet-ajax/window-controls-container.html.

Dojo EnhancedGrid and programmatic selection

Here's my problem: in my application I have a Dojo EnhancedGrid, backed up by an ItemFileReadStore. The page flow looks like this:
The user selects a value from a selection list.
The item from the list is posted on a server and then the grid is updated with data from the server (don't ask why, this is how it's supposed to work)
The new item is highlighted in the grid.
Now, the first two steps work like a charm; however, the third step gave me some headaches. After the data is successfully POSTed to the server (via dojo.xhrPost() ) the following code runs:
myGrid.store.close();
myGrid._refresh();
myGrid.store.fetch({
onComplete : function(items) {
for ( var i = 0; i < items.length; i++) {
if (items[i].documentType[0].id == documentTypeId) {
var newItemIndex = myGrid.getItemIndex(items[i]);
exportMappingGrid.selection.deselectAll();
exportMappingGrid.selection.addToSelection(newItemIndex);
}
}
}
});
Now, the selection of the grid is updated (i.e. the selection object has a selectedIndex > 0), but visually there's no response, unless I hover the mouse over the "selected" row. If I remove the .deselectAll() line (which I suspected as the culprit) then I sometimes end up with two items selected at once, although the grid selectionMode attribute is set to single.
Any thoughts on this one?
Thanks a lot.
You need to use setSelected(), like so
exportMappingGrid.selection.setSelected(newItemIndex, true);
The second parameter is true to select the row, false to unselect it.
This is what works for me:
grid.selection.clear();
grid.selection.addToSelection(newItemIndex);
grid.selection.getFirstSelected();
Jon

Checked ToolStrip Submenu Items

I'm trying to create a menu in VB.Net where one item in the menu has a submenu that sprouts off to the side when the user hovers over it. In other words, a completely ordinary submenu that everyone's used a million times.
My main menu items are of class ToolStripMenuItem. I can get close to the behavior I want by using the item's "DropDown" member. This creates the submenu behavior correctly, but I also need to be able to check and uncheck the items in the submenu. I've set the submenu items' "CheckOnClick" property to True, but checkboxes are still not displayed when I run the program.
Is it possible to get this behavior? Is it possible with ToolStripMenuItem?
Here's the code I currently have, which gets close, but doesn't give me checkboxes:
Dim mainItem As ToolStripMenuItem = New ToolStripMenuItem()
mainItem.Text = "Click For Submenu"
Dim subMenu As ToolStripDropDown = New ToolStripDropDown()
For Each item As ToolStripMenuItem In listOfItems
item.CheckOnClick = True
subMenu.Items.Add(item)
Next
mainItem.DropDown = subMenu
Try getting rid of that subMenu variable and change the code this way:
For Each mi As ToolStripMenuItem In listOfItems
mi.CheckOnClick = True
mainItem.DropDownItems.Add(mi)
Next

vb.net tabpage using a form for tabpanels issues

I have a simple vb.net form a tabpanel strip, and then a seperate form which is loaded for the tabpage.
Here is the code for the button that dynamically creates new tabs:
Dim tempTab As New TabPage
initTab(tempTab)
xt.TabPages.Add(tempTab)
xt.SelectedIndex = xt.TabCount - 1
Here is the code for the "initTab":
Dim tmpTab As New MainTab
tmpTab.Dock = DockStyle.Fill
tmpTab.Panel1.Dock = DockStyle.Fill
tab.Controls.Add(tmpTab)
tab.Text = "Untitled"
tab.Name = " "
I can easily set the focus of any tab by entering following which sets the focus for example to the last tab:
xt.SelectedIndex = xt.TabCount - 1
Now the issue is, how can I set the focus to a textbox on the custom form (in my example labeled "MainTab")? I've tried virtually everything I can google and I can't seem to find any example of how to setfocus or even set/get anything from the MainTab form.
Anyone can help me?
Erm, turning a form into a child control takes some surgery. You have to set its TopLevel property to false, hide the border, make it visible. I don't see it in the code snippet, is MainTab actually a form?
Anyhoo, you cannot use the Focus() method on a control until it is visible. Odds are good that it isn't visible yet in your code snippet. Use the Select() method instead. Say:
tmpTab.TextBox1.Select()
Or just set the TabIndex property of the first control that should get the focus to 0 in the designer.
xt.Controls(xt.SelectedIndex).Controls("TEXTBOXNAME").Focus()
Just make sure that you set the Name property of the textbox you want to have focus (in this case the name would be TEXTBOXNAME) if you do it like this.